From 7e5a670846186ced8faedb5ad8d3c411194521b3 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Tue, 24 Nov 2020 09:20:43 -0500 Subject: [PATCH 1/6] Http client update (#378) * wip * tests all pass with log outputs identical to original...is it better now? I don't know. * proxy works, adding a test and docs next * more cleanup and test fixes * left in testing file * didn't need that code anymore --- org.hl7.fhir.r5/pom.xml | 12 + .../hl7/fhir/r5/utils/client/ClientUtils.java | 684 ----------- .../r5/utils/client/EFhirClientException.java | 1 - .../r5/utils/client/FHIRToolingClient.java | 1010 +++++------------ .../fhir/r5/utils/client/ResourceAddress.java | 3 - .../fhir/r5/utils/client/ResourceRequest.java | 109 -- .../r5/utils/client/network/ByteUtils.java | 69 ++ .../fhir/r5/utils/client/network/Client.java | 234 ++++ .../client/network/FhirRequestBuilder.java | 339 ++++++ .../utils/client/network/ResourceRequest.java | 71 ++ .../client/network/RetryInterceptor.java | 63 + .../r5/utils/client/network/ClientTest.java | 146 +++ .../network/FhirRequestBuilderTest.java | 147 +++ .../org/hl7/fhir/validation/ValidatorCli.java | 46 +- .../hl7/fhir/validation/cli/utils/Params.java | 4 + 15 files changed, 1443 insertions(+), 1495 deletions(-) delete mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ClientUtils.java delete mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceRequest.java create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ByteUtils.java create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/Client.java create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilder.java create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ResourceRequest.java create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/RetryInterceptor.java create mode 100644 org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java create mode 100644 org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 4721999c4..f77ef03fd 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -101,6 +101,11 @@ httpclient true + + com.squareup.okhttp3 + okhttp + 4.9.0 + @@ -119,6 +124,13 @@ ${validator_test_case_version} test + + com.squareup.okhttp3 + mockwebserver + 4.9.0 + test + + diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ClientUtils.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ClientUtils.java deleted file mode 100644 index 1688c010f..000000000 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ClientUtils.java +++ /dev/null @@ -1,684 +0,0 @@ -package org.hl7.fhir.r5.utils.client; - - - - - -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - */ - - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URLConnection; -import java.nio.charset.StandardCharsets; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.Header; -import org.apache.http.HttpEntityEnclosingRequest; -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.conn.params.ConnRoutePNames; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; -import org.hl7.fhir.r5.formats.IParser; -import org.hl7.fhir.r5.formats.IParser.OutputStyle; -import org.hl7.fhir.r5.formats.JsonParser; -import org.hl7.fhir.r5.formats.XmlParser; -import org.hl7.fhir.r5.model.Bundle; -import org.hl7.fhir.r5.model.OperationOutcome; -import org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity; -import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; -import org.hl7.fhir.r5.model.Resource; -import org.hl7.fhir.r5.model.ResourceType; -import org.hl7.fhir.r5.utils.ResourceUtilities; -import org.hl7.fhir.utilities.ToolingClientLogger; -import org.hl7.fhir.utilities.Utilities; - -/** - * Helper class handling lower level HTTP transport concerns. - * TODO Document methods. - * @author Claude Nanjo - */ -public class ClientUtils { - - public static final String DEFAULT_CHARSET = "UTF-8"; - public static final String HEADER_LOCATION = "location"; - private static boolean debugging = false; - public static final int TIMEOUT_SOCKET = 5000; - public static final int TIMEOUT_CONNECT = 1000; - - private HttpHost proxy; - private int timeout = TIMEOUT_SOCKET; - private String username; - private String password; - private ToolingClientLogger logger; - private int retryCount; - private HttpClient httpclient; - - public HttpHost getProxy() { - return proxy; - } - - public void setProxy(HttpHost proxy) { - this.proxy = proxy; - } - - public int getTimeout() { - return timeout; - } - - public void setTimeout(int timeout) { - this.timeout = timeout; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public ResourceRequest issueOptionsRequest(URI optionsUri, String resourceFormat, String message, int timeout) { - HttpOptions options = new HttpOptions(optionsUri); - return issueResourceRequest(resourceFormat, options, message, timeout); - } - - public ResourceRequest issueGetResourceRequest(URI resourceUri, String resourceFormat, String message, int timeout) { - HttpGet httpget = new HttpGet(resourceUri); - return issueResourceRequest(resourceFormat, httpget, message, timeout); - } - - public ResourceRequest issuePutRequest(URI resourceUri, byte[] payload, String resourceFormat, List
headers, String message, int timeout) { - HttpPut httpPut = new HttpPut(resourceUri); - return issueResourceRequest(resourceFormat, httpPut, payload, headers, message, timeout); - } - - public ResourceRequest issuePutRequest(URI resourceUri, byte[] payload, String resourceFormat, String message, int timeout) { - HttpPut httpPut = new HttpPut(resourceUri); - return issueResourceRequest(resourceFormat, httpPut, payload, null, message, timeout); - } - - public ResourceRequest issuePostRequest(URI resourceUri, byte[] payload, String resourceFormat, List
headers, String message, int timeout) { - HttpPost httpPost = new HttpPost(resourceUri); - return issueResourceRequest(resourceFormat, httpPost, payload, headers, message, timeout); - } - - - public ResourceRequest issuePostRequest(URI resourceUri, byte[] payload, String resourceFormat, String message, int timeout) { - return issuePostRequest(resourceUri, payload, resourceFormat, null, message, timeout); - } - - public Bundle issueGetFeedRequest(URI resourceUri, String resourceFormat) { - HttpGet httpget = new HttpGet(resourceUri); - configureFhirRequest(httpget, resourceFormat); - HttpResponse response = sendRequest(httpget); - return unmarshalReference(response, resourceFormat); - } - - private void setAuth(HttpRequest httpget) { - if (password != null) { - try { - byte[] b = Base64.encodeBase64((username+":"+password).getBytes("ASCII")); - String b64 = new String(b, StandardCharsets.US_ASCII); - httpget.setHeader("Authorization", "Basic " + b64); - } catch (UnsupportedEncodingException e) { - } - } - } - - public Bundle postBatchRequest(URI resourceUri, byte[] payload, String resourceFormat, String message, int timeout) { - HttpPost httpPost = new HttpPost(resourceUri); - configureFhirRequest(httpPost, resourceFormat); - HttpResponse response = sendPayload(httpPost, payload, proxy, message, timeout); - return unmarshalFeed(response, resourceFormat); - } - - public boolean issueDeleteRequest(URI resourceUri) { - HttpDelete deleteRequest = new HttpDelete(resourceUri); - HttpResponse response = sendRequest(deleteRequest); - int responseStatusCode = response.getStatusLine().getStatusCode(); - boolean deletionSuccessful = false; - if(responseStatusCode == 204) { - deletionSuccessful = true; - } - return deletionSuccessful; - } - - /*********************************************************** - * Request/Response Helper methods - ***********************************************************/ - - protected ResourceRequest issueResourceRequest(String resourceFormat, HttpUriRequest request, String message, int timeout) { - return issueResourceRequest(resourceFormat, request, null, message, timeout); - } - - /** - * @param resourceFormat - * @param options - * @return - */ - protected ResourceRequest issueResourceRequest(String resourceFormat, HttpUriRequest request, byte[] payload, String message, int timeout) { - return issueResourceRequest(resourceFormat, request, payload, null, message, timeout); - } - - /** - * @param resourceFormat - * @param options - * @return - */ - protected ResourceRequest issueResourceRequest(String resourceFormat, HttpUriRequest request, byte[] payload, List
headers, String message, int timeout) { - configureFhirRequest(request, resourceFormat, headers); - HttpResponse response = null; - if(request instanceof HttpEntityEnclosingRequest && payload != null) { - response = sendPayload((HttpEntityEnclosingRequestBase)request, payload, proxy, message, timeout); - } else if (request instanceof HttpEntityEnclosingRequest && payload == null){ - throw new EFhirClientException("PUT and POST requests require a non-null payload"); - } else { - response = sendRequest(request); - } - T resource = unmarshalReference(response, resourceFormat); - return new ResourceRequest(resource, response.getStatusLine().getStatusCode(), getLocationHeader(response)); - } - - - /** - * Method adds required request headers. - * TODO handle JSON request as well. - * - * @param request - */ - protected void configureFhirRequest(HttpRequest request, String format) { - configureFhirRequest(request, format, null); - } - - /** - * Method adds required request headers. - * TODO handle JSON request as well. - * - * @param request - */ - protected void configureFhirRequest(HttpRequest request, String format, List
headers) { - request.addHeader("User-Agent", "hapi-fhir-tooling-client"); - - if (format != null) { - request.addHeader("Accept",format); - request.addHeader("Content-Type", format + ";charset=" + DEFAULT_CHARSET); - } - request.addHeader("Accept-Charset", DEFAULT_CHARSET); - if(headers != null) { - for(Header header : headers) { - request.addHeader(header); - } - } - setAuth(request); - } - - /** - * Method posts request payload - * - * @param request - * @param payload - * @return - */ - @SuppressWarnings({ "resource", "deprecation" }) - protected HttpResponse sendPayload(HttpEntityEnclosingRequestBase request, byte[] payload, HttpHost proxy, String message, int timeout) { - HttpResponse response = null; - boolean ok = false; - long t = System.currentTimeMillis(); - int tryCount = 0; - while (!ok) { - try { - tryCount++; - if (httpclient == null) { - makeClient(proxy); - } - HttpParams params = httpclient.getParams(); - HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000); - request.setEntity(new ByteArrayEntity(payload)); - log(request); - response = httpclient.execute(request); - ok = true; - } catch(IOException ioe) { - System.out.println(ioe.getMessage()+" ("+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")"); - if (tryCount <= retryCount || (tryCount < 3 && ioe instanceof org.apache.http.conn.ConnectTimeoutException)) { - ok = false; - try { - Thread.sleep(100); - } catch (InterruptedException e) { - } - } else { - if (tryCount > 4) { - System.out.println("Giving up: "+ioe.getMessage()+" (R5 / "+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")"); - } - throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe); - } - } - } - return response; - } - - @SuppressWarnings("deprecation") - public void makeClient(HttpHost proxy) { - httpclient = new DefaultHttpClient(); - HttpParams params = httpclient.getParams(); - HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT); - HttpConnectionParams.setSoTimeout(params, timeout); - HttpConnectionParams.setSoKeepalive(params, true); - if(proxy != null) { - httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); - } - } - - /** - * - * @param request - * @param payload - * @return - */ - protected HttpResponse sendRequest(HttpUriRequest request) { - HttpResponse response = null; - try { - if (httpclient == null) { - makeClient(proxy); - } - response = httpclient.execute(request); - } catch(IOException ioe) { - if (ClientUtils.debugging ) { - ioe.printStackTrace(); - } - throw new EFhirClientException("Error sending Http Request: "+ioe.getMessage(), ioe); - } - return response; - } - - - /** - * Unmarshals a resource from the response stream. - * - * @param response - * @return - */ - @SuppressWarnings("unchecked") - protected T unmarshalReference(HttpResponse response, String format) { - T resource = null; - OperationOutcome error = null; - byte[] cnt = log(response); - if (cnt != null) { - try { - resource = (T)getParser(format).parse(cnt); - if (resource instanceof OperationOutcome && hasError((OperationOutcome)resource)) { - error = (OperationOutcome) resource; - } - } catch(IOException ioe) { - throw new EFhirClientException("Error reading Http Response: "+ioe.getMessage(), ioe); - } catch(Exception e) { - throw new EFhirClientException("Error parsing response message: "+e.getMessage(), e); - } - } - if(error != null) { - throw new EFhirClientException("Error from server: "+ResourceUtilities.getErrorDescription(error), error); - } - return resource; - } - - /** - * Unmarshals Bundle from response stream. - * - * @param response - * @return - */ - protected Bundle unmarshalFeed(HttpResponse response, String format) { - Bundle feed = null; - byte[] cnt = log(response); - String contentType = response.getHeaders("Content-Type")[0].getValue(); - OperationOutcome error = null; - try { - if (cnt != null) { - if(contentType.contains(ResourceFormat.RESOURCE_XML.getHeader()) || contentType.contains("text/xml+fhir")) { - Resource rf = getParser(format).parse(cnt); - if (rf instanceof Bundle) - feed = (Bundle) rf; - else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) { - error = (OperationOutcome) rf; - } else { - throw new EFhirClientException("Error reading server response: a resource was returned instead"); - } - } - } - } catch(IOException ioe) { - throw new EFhirClientException("Error reading Http Response", ioe); - } catch(Exception e) { - throw new EFhirClientException("Error parsing response message", e); - } - if(error != null) { - throw new EFhirClientException("Error from server: "+ResourceUtilities.getErrorDescription(error), error); - } - return feed; - } - - private boolean hasError(OperationOutcome oo) { - for (OperationOutcomeIssueComponent t : oo.getIssue()) - if (t.getSeverity() == IssueSeverity.ERROR || t.getSeverity() == IssueSeverity.FATAL) - return true; - return false; - } - - protected String getLocationHeader(HttpResponse response) { - String location = null; - if(response.getHeaders("location").length > 0) {//TODO Distinguish between both cases if necessary - location = response.getHeaders("location")[0].getValue(); - } else if(response.getHeaders("content-location").length > 0) { - location = response.getHeaders("content-location")[0].getValue(); - } - return location; - } - - - /***************************************************************** - * Client connection methods - * ***************************************************************/ - - public HttpURLConnection buildConnection(URI baseServiceUri, String tail) { - try { - HttpURLConnection client = (HttpURLConnection) baseServiceUri.resolve(tail).toURL().openConnection(); - return client; - } catch(MalformedURLException mue) { - throw new EFhirClientException("Invalid Service URL", mue); - } catch(IOException ioe) { - throw new EFhirClientException("Unable to establish connection to server: " + baseServiceUri.toString() + tail, ioe); - } - } - - public HttpURLConnection buildConnection(URI baseServiceUri, ResourceType resourceType, String id) { - return buildConnection(baseServiceUri, ResourceAddress.buildRelativePathFromResourceType(resourceType, id)); - } - - /****************************************************************** - * Other general helper methods - * ****************************************************************/ - - - public byte[] getResourceAsByteArray(T resource, boolean pretty, boolean isJson) { - ByteArrayOutputStream baos = null; - byte[] byteArray = null; - try { - baos = new ByteArrayOutputStream(); - IParser parser = null; - if(isJson) { - parser = new JsonParser(); - } else { - parser = new XmlParser(); - } - parser.setOutputStyle(pretty ? OutputStyle.PRETTY : OutputStyle.NORMAL); - parser.compose(baos, resource); - baos.close(); - byteArray = baos.toByteArray(); - baos.close(); - } catch (Exception e) { - try{ - baos.close(); - }catch(Exception ex) { - throw new EFhirClientException("Error closing output stream", ex); - } - throw new EFhirClientException("Error converting output stream to byte array", e); - } - return byteArray; - } - - public byte[] getFeedAsByteArray(Bundle feed, boolean pretty, boolean isJson) { - ByteArrayOutputStream baos = null; - byte[] byteArray = null; - try { - baos = new ByteArrayOutputStream(); - IParser parser = null; - if(isJson) { - parser = new JsonParser(); - } else { - parser = new XmlParser(); - } - parser.setOutputStyle(pretty ? OutputStyle.PRETTY : OutputStyle.NORMAL); - parser.compose(baos, feed); - baos.close(); - byteArray = baos.toByteArray(); - baos.close(); - } catch (Exception e) { - try{ - baos.close(); - }catch(Exception ex) { - throw new EFhirClientException("Error closing output stream", ex); - } - throw new EFhirClientException("Error converting output stream to byte array", e); - } - return byteArray; - } - - public Calendar getLastModifiedResponseHeaderAsCalendarObject(URLConnection serverConnection) { - String dateTime = null; - try { - dateTime = serverConnection.getHeaderField("Last-Modified"); - SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", new Locale("en", "US")); - Date lastModifiedTimestamp = format.parse(dateTime); - Calendar calendar=Calendar.getInstance(); - calendar.setTime(lastModifiedTimestamp); - return calendar; - } catch(ParseException pe) { - throw new EFhirClientException("Error parsing Last-Modified response header " + dateTime, pe); - } - } - - protected IParser getParser(String format) { - if(StringUtils.isBlank(format)) { - format = ResourceFormat.RESOURCE_XML.getHeader(); - } - if(format.equalsIgnoreCase("json") || format.equalsIgnoreCase(ResourceFormat.RESOURCE_JSON.getHeader()) || format.equalsIgnoreCase(ResourceFormat.RESOURCE_JSON.getHeader())) { - return new JsonParser(); - } else if(format.equalsIgnoreCase("xml") || format.equalsIgnoreCase(ResourceFormat.RESOURCE_XML.getHeader()) || format.equalsIgnoreCase(ResourceFormat.RESOURCE_XML.getHeader())) { - return new XmlParser(); - } else { - throw new EFhirClientException("Invalid format: " + format); - } - } - - public Bundle issuePostFeedRequest(URI resourceUri, Map parameters, String resourceName, Resource resource, String resourceFormat) throws IOException { - HttpPost httppost = new HttpPost(resourceUri); - String boundary = "----WebKitFormBoundarykbMUo6H8QaUnYtRy"; - httppost.addHeader("Content-Type", "multipart/form-data; boundary="+boundary); - httppost.addHeader("Accept", resourceFormat); - configureFhirRequest(httppost, null); - HttpResponse response = sendPayload(httppost, encodeFormSubmission(parameters, resourceName, resource, boundary)); - return unmarshalFeed(response, resourceFormat); - } - - private byte[] encodeFormSubmission(Map parameters, String resourceName, Resource resource, String boundary) throws IOException { - ByteArrayOutputStream b = new ByteArrayOutputStream(); - OutputStreamWriter w = new OutputStreamWriter(b, "UTF-8"); - for (String name : parameters.keySet()) { - w.write("--"); - w.write(boundary); - w.write("\r\nContent-Disposition: form-data; name=\""+name+"\"\r\n\r\n"); - w.write(parameters.get(name)+"\r\n"); - } - w.write("--"); - w.write(boundary); - w.write("\r\nContent-Disposition: form-data; name=\""+resourceName+"\"\r\n\r\n"); - w.close(); - JsonParser json = new JsonParser(); - json.setOutputStyle(OutputStyle.NORMAL); - json.compose(b, resource); - b.close(); - w = new OutputStreamWriter(b, "UTF-8"); - w.write("\r\n--"); - w.write(boundary); - w.write("--"); - w.close(); - return b.toByteArray(); - } - - /** - * Method posts request payload - * - * @param request - * @param payload - * @return - */ - protected HttpResponse sendPayload(HttpEntityEnclosingRequestBase request, byte[] payload) { - HttpResponse response = null; - try { - log(request); - if (httpclient == null) { - makeClient(proxy); - } - request.setEntity(new ByteArrayEntity(payload)); - response = httpclient.execute(request); - log(response); - } catch(IOException ioe) { - throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe); - } - return response; - } - - private void log(HttpUriRequest request) { - if (logger != null) { - List headers = new ArrayList<>(); - for (Header h : request.getAllHeaders()) { - headers.add(h.toString()); - } - logger.logRequest(request.getMethod(), request.getURI().toString(), headers, null); - } - } - private void log(HttpEntityEnclosingRequestBase request) { - if (logger != null) { - List headers = new ArrayList<>(); - for (Header h : request.getAllHeaders()) { - headers.add(h.toString()); - } - byte[] cnt = null; - InputStream s; - try { - s = request.getEntity().getContent(); - cnt = IOUtils.toByteArray(s); - s.close(); - } catch (Exception e) { - } - logger.logRequest(request.getMethod(), request.getURI().toString(), headers, cnt); - } - } - - private byte[] log(HttpResponse response) { - byte[] cnt = null; - try { - InputStream s = response.getEntity().getContent(); - cnt = IOUtils.toByteArray(s); - s.close(); - } catch (Exception e) { - } - if (logger != null) { - List headers = new ArrayList<>(); - for (Header h : response.getAllHeaders()) { - headers.add(h.toString()); - } - logger.logResponse(response.getStatusLine().toString(), headers, cnt); - } - return cnt; - } - - public ToolingClientLogger getLogger() { - return logger; - } - - public void setLogger(ToolingClientLogger logger) { - this.logger = logger; - } - - - /** - * Used for debugging - * - * @param instream - * @return - */ - protected String writeInputStreamAsString(InputStream instream) { - String value = null; - try { - value = IOUtils.toString(instream, "UTF-8"); - System.out.println(value); - - } catch(IOException ioe) { - //Do nothing - } - return value; - } - - public int getRetryCount() { - return retryCount; - } - - public void setRetryCount(int retryCount) { - this.retryCount = retryCount; - } - - -} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/EFhirClientException.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/EFhirClientException.java index 8171150bc..8b01df1ac 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/EFhirClientException.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/EFhirClientException.java @@ -99,7 +99,6 @@ public class EFhirClientException extends RuntimeException { * A default message of "One or more server side errors have occurred during this operation. Refer to e.getServerErrors() for additional details." * will be returned to users. * - * @param message * @param serverError */ public EFhirClientException(OperationOutcome serverError) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java index 1e9c94af7..51eee8a1f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java @@ -29,739 +29,374 @@ package org.hl7.fhir.r5.utils.client; */ -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.http.Header; -import org.apache.http.HttpHost; -import org.hl7.fhir.r5.model.Bundle; -import org.hl7.fhir.r5.model.CapabilityStatement; -import org.hl7.fhir.r5.model.CodeSystem; -import org.hl7.fhir.r5.model.Coding; -import org.hl7.fhir.r5.model.ConceptMap; -import org.hl7.fhir.r5.model.OperationOutcome; -import org.hl7.fhir.r5.model.Parameters; +import org.hl7.fhir.r5.model.*; import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent; -import org.hl7.fhir.r5.model.PrimitiveType; -import org.hl7.fhir.r5.model.Resource; -import org.hl7.fhir.r5.model.StringType; -import org.hl7.fhir.r5.model.TerminologyCapabilities; -import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.utils.client.network.ByteUtils; +import org.hl7.fhir.r5.utils.client.network.Client; +import org.hl7.fhir.r5.utils.client.network.ResourceRequest; import org.hl7.fhir.utilities.ToolingClientLogger; import org.hl7.fhir.utilities.Utilities; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.Map; + /** - * Very Simple RESTful client. This is purely for use in the standalone + * Very Simple RESTful client. This is purely for use in the standalone * tools jar packages. It doesn't support many features, only what the tools * need. - * + *

* To use, initialize class and set base service URI as follows: - * + * *


  * FHIRSimpleClient fhirClient = new FHIRSimpleClient();
  * fhirClient.initialize("http://my.fhir.domain/myServiceRoot");
  * 
- * + *

* Default Accept and Content-Type headers are application/fhir+xml and application/fhir+json. - * + *

* These can be changed by invoking the following setter functions: - * + * *


  * setPreferredResourceFormat()
  * setPreferredFeedFormat()
  * 
- * - * TODO Review all sad paths. - * - * @author Claude Nanjo + *

+ * TODO Review all sad paths. * + * @author Claude Nanjo */ public class FHIRToolingClient { - - public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssK"; - public static final String DATE_FORMAT = "yyyy-MM-dd"; - public static final String hostKey = "http.proxyHost"; - public static final String portKey = "http.proxyPort"; - private static final int TIMEOUT_NORMAL = 15; - private static final int TIMEOUT_OPERATION = 30; - private static final int TIMEOUT_OPERATION_LONG = 60; - private static final int TIMEOUT_OPERATION_EXPAND = 120; - - private String base; - private ResourceAddress resourceAddress; - private ResourceFormat preferredResourceFormat; - private int maxResultSetSize = -1;//_count - private CapabilityStatement capabilities; - private ClientUtils utils = new ClientUtils(); - - //Pass enpoint for client - URI + public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssK"; + public static final String DATE_FORMAT = "yyyy-MM-dd"; + public static final String hostKey = "http.proxyHost"; + public static final String portKey = "http.proxyPort"; + + private static final int TIMEOUT_NORMAL = 1500; + private static final int TIMEOUT_OPERATION = 30000; + private static final int TIMEOUT_OPERATION_LONG = 60000; + private static final int TIMEOUT_OPERATION_EXPAND = 120000; + + private String base; + private ResourceAddress resourceAddress; + private ResourceFormat preferredResourceFormat; + private int maxResultSetSize = -1;//_count + private CapabilityStatement capabilities; + private Client client = new Client(); + + //Pass enpoint for client - URI public FHIRToolingClient(String baseServiceUrl) throws URISyntaxException { preferredResourceFormat = ResourceFormat.RESOURCE_XML; - detectProxy(); initialize(baseServiceUrl); } - - public FHIRToolingClient(String baseServiceUrl, String username, String password) throws URISyntaxException { - preferredResourceFormat = ResourceFormat.RESOURCE_XML; - utils.setUsername(username); - utils.setPassword(password); - detectProxy(); - initialize(baseServiceUrl); - } - - public void configureProxy(String proxyHost, int proxyPort) { - utils.setProxy(new HttpHost(proxyHost, proxyPort)); - } - - public void detectProxy() { - String host = System.getenv(hostKey); - String port = System.getenv(portKey); - if(host==null) { - host = System.getProperty(hostKey); - } - - if(port==null) { - port = System.getProperty(portKey); - } - - if(host!=null && port!=null) { - this.configureProxy(host, Integer.parseInt(port)); - } - } - - public void initialize(String baseServiceUrl) throws URISyntaxException { - base = baseServiceUrl; - resourceAddress = new ResourceAddress(baseServiceUrl); - this.maxResultSetSize = -1; - checkCapabilities(); - } - - private void checkCapabilities() { - try { + public void initialize(String baseServiceUrl) throws URISyntaxException { + base = baseServiceUrl; + resourceAddress = new ResourceAddress(baseServiceUrl); + this.maxResultSetSize = -1; + checkCapabilities(); + } + + private void checkCapabilities() { + try { capabilities = getCapabilitiesStatementQuick(); - } catch (Throwable e) { - } - } + } catch (Throwable e) { + } + } public String getPreferredResourceFormat() { return preferredResourceFormat.getHeader(); } - - public void setPreferredResourceFormat(ResourceFormat resourceFormat) { - preferredResourceFormat = resourceFormat; - } - - public int getMaximumRecordCount() { - return maxResultSetSize; - } - - public void setMaximumRecordCount(int maxResultSetSize) { - this.maxResultSetSize = maxResultSetSize; - } - - public TerminologyCapabilities getTerminologyCapabilities() { - return (TerminologyCapabilities) utils.issueGetResourceRequest(resourceAddress.resolveMetadataTxCaps(), getPreferredResourceFormat(), "TerminologyCapabilities", TIMEOUT_NORMAL).getReference(); - } - - public CapabilityStatement getCapabilitiesStatement() { - CapabilityStatement conformance = null; - try { - conformance = (CapabilityStatement)utils.issueGetResourceRequest(resourceAddress.resolveMetadataUri(false), getPreferredResourceFormat(), "CapabilitiesStatement", TIMEOUT_NORMAL).getReference(); - } catch(Exception e) { - handleException("An error has occurred while trying to fetch the server's conformance statement", e); - } - return conformance; - } - - public CapabilityStatement getCapabilitiesStatementQuick() throws EFhirClientException { - if (capabilities != null) - return capabilities; + + public void setPreferredResourceFormat(ResourceFormat resourceFormat) { + preferredResourceFormat = resourceFormat; + } + + public int getMaximumRecordCount() { + return maxResultSetSize; + } + + public void setMaximumRecordCount(int maxResultSetSize) { + this.maxResultSetSize = maxResultSetSize; + } + + public TerminologyCapabilities getTerminologyCapabilities() { + TerminologyCapabilities capabilities = null; try { - capabilities = (CapabilityStatement)utils.issueGetResourceRequest(resourceAddress.resolveMetadataUri(true), getPreferredResourceFormat(), "CapabilitiesStatement-Quick", TIMEOUT_NORMAL).getReference(); - } catch(Exception e) { + capabilities = (TerminologyCapabilities) client.issueGetResourceRequest(resourceAddress.resolveMetadataTxCaps(), + getPreferredResourceFormat(), "TerminologyCapabilities", TIMEOUT_NORMAL).getReference(); + } catch (Exception e) { + handleException("An error has occurred while trying to fetch the server's terminology capabilities", e); + } + return capabilities; + } + + public CapabilityStatement getCapabilitiesStatement() { + CapabilityStatement conformance = null; + try { + conformance = (CapabilityStatement) client.issueGetResourceRequest(resourceAddress.resolveMetadataUri(false), + getPreferredResourceFormat(), "CapabilitiesStatement", TIMEOUT_NORMAL).getReference(); + } catch (Exception e) { + handleException("An error has occurred while trying to fetch the server's conformance statement", e); + } + return conformance; + } + + public CapabilityStatement getCapabilitiesStatementQuick() throws EFhirClientException { + if (capabilities != null) return capabilities; + try { + capabilities = (CapabilityStatement) client.issueGetResourceRequest(resourceAddress.resolveMetadataUri(true), + getPreferredResourceFormat(), "CapabilitiesStatement-Quick", TIMEOUT_NORMAL).getReference(); + } catch (Exception e) { handleException("An error has occurred while trying to fetch the server's conformance statement", e); } return capabilities; } - - public T read(Class resourceClass, String id) {//TODO Change this to AddressableResource - ResourceRequest result = null; - try { - result = utils.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id), getPreferredResourceFormat(), "Read "+resourceClass.getName()+"/"+id, TIMEOUT_NORMAL); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addSuccessStatus(200);//Only one for now - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); - } - } catch (Exception e) { - handleException("An error has occurred while trying to read this resource", e); - } - return result.getPayload(); - } - public T vread(Class resourceClass, String id, String version) { - ResourceRequest result = null; - try { - result = utils.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndIdAndVersion(resourceClass, id, version), getPreferredResourceFormat(), "VRead "+resourceClass.getName()+"/"+id+"/?_history/"+version, TIMEOUT_NORMAL); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405);//unknown - result.addSuccessStatus(200);//Only one for now - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); - } - } catch (Exception e) { - handleException("An error has occurred while trying to read this version of the resource", e); - } - return result.getPayload(); - } - - // GET fhir/ValueSet?url=http://hl7.org/fhir/ValueSet/clinical-findings&version=0.8 + public T read(Class resourceClass, String id) {//TODO Change this to AddressableResource + ResourceRequest result = null; + try { + result = client.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id), + getPreferredResourceFormat(), "Read " + resourceClass.getName() + "/" + id, TIMEOUT_NORMAL); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); + } + } catch (Exception e) { + handleException("An error has occurred while trying to read this resource", e); + } + return result.getPayload(); + } + + public T vread(Class resourceClass, String id, String version) { + ResourceRequest result = null; + try { + result = client.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndIdAndVersion(resourceClass, id, version), + getPreferredResourceFormat(), "VRead " + resourceClass.getName() + "/" + id + "/?_history/" + version, TIMEOUT_NORMAL); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); + } + } catch (Exception e) { + handleException("An error has occurred while trying to read this version of the resource", e); + } + return result.getPayload(); + } public T getCanonical(Class resourceClass, String canonicalURL) { ResourceRequest result = null; try { - result = utils.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndCanonical(resourceClass, canonicalURL), getPreferredResourceFormat(), "Read "+resourceClass.getName()+"?url="+canonicalURL, TIMEOUT_NORMAL); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405);//unknown - result.addSuccessStatus(200);//Only one for now - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + result = client.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndCanonical(resourceClass, canonicalURL), + getPreferredResourceFormat(), "Read " + resourceClass.getName() + "?url=" + canonicalURL, TIMEOUT_NORMAL); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } } catch (Exception e) { handleException("An error has occurred while trying to read this version of the resource", e); } Bundle bnd = (Bundle) result.getPayload(); if (bnd.getEntry().size() == 0) - throw new EFhirClientException("No matching resource found for canonical URL '"+canonicalURL+"'"); + throw new EFhirClientException("No matching resource found for canonical URL '" + canonicalURL + "'"); if (bnd.getEntry().size() > 1) - throw new EFhirClientException("Multiple matching resources found for canonical URL '"+canonicalURL+"'"); + throw new EFhirClientException("Multiple matching resources found for canonical URL '" + canonicalURL + "'"); return (T) bnd.getEntry().get(0).getResource(); } - - + public Resource update(Resource resource) { - ResourceRequest result = null; + org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; try { - List

headers = null; - result = utils.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()),utils.getResourceAsByteArray(resource, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, - "Update "+resource.fhirType()+"/"+resource.getId(), TIMEOUT_OPERATION); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resource.getClass(), resource.getId()), + ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), + "Update " + resource.fhirType() + "/" + resource.getId(), TIMEOUT_OPERATION); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } - } catch(Exception e) { + } catch (Exception e) { throw new EFhirClientException("An error has occurred while trying to update this resource", e); } // TODO oe 26.1.2015 could be made nicer if only OperationOutcome locationheader is returned with an operationOutcome would be returned (and not the resource also) we make another read try { - OperationOutcome operationOutcome = (OperationOutcome)result.getPayload(); + OperationOutcome operationOutcome = (OperationOutcome) result.getPayload(); ResourceAddress.ResourceVersionedIdentifier resVersionedIdentifier = ResourceAddress.parseCreateLocation(result.getLocation()); - return this.vread(resource.getClass(), resVersionedIdentifier.getId(),resVersionedIdentifier.getVersionId()); - } catch(ClassCastException e) { + return this.vread(resource.getClass(), resVersionedIdentifier.getId(), resVersionedIdentifier.getVersionId()); + } catch (ClassCastException e) { // if we fall throught we have the correct type already in the create } return result.getPayload(); } - public T update(Class resourceClass, T resource, String id) { - ResourceRequest result = null; - try { - List
headers = null; - result = utils.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id),utils.getResourceAsByteArray(resource, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, - "Update "+resource.fhirType()+"/"+id, TIMEOUT_OPERATION); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); - } - } catch(Exception e) { - throw new EFhirClientException("An error has occurred while trying to update this resource", e); - } - // TODO oe 26.1.2015 could be made nicer if only OperationOutcome locationheader is returned with an operationOutcome would be returned (and not the resource also) we make another read - try { - OperationOutcome operationOutcome = (OperationOutcome)result.getPayload(); - ResourceAddress.ResourceVersionedIdentifier resVersionedIdentifier = ResourceAddress.parseCreateLocation(result.getLocation()); - return this.vread(resourceClass, resVersionedIdentifier.getId(),resVersionedIdentifier.getVersionId()); - } catch(ClassCastException e) { - // if we fall throught we have the correct type already in the create - } + public T update(Class resourceClass, T resource, String id) { + ResourceRequest result = null; + try { + result = client.issuePutRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id), + ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())), + getPreferredResourceFormat(),"Update " + resource.fhirType() + "/" + id, TIMEOUT_OPERATION); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); + } + } catch (Exception e) { + throw new EFhirClientException("An error has occurred while trying to update this resource", e); + } + // TODO oe 26.1.2015 could be made nicer if only OperationOutcome locationheader is returned with an operationOutcome would be returned (and not the resource also) we make another read + try { + OperationOutcome operationOutcome = (OperationOutcome) result.getPayload(); + ResourceAddress.ResourceVersionedIdentifier resVersionedIdentifier = ResourceAddress.parseCreateLocation(result.getLocation()); + return this.vread(resourceClass, resVersionedIdentifier.getId(), resVersionedIdentifier.getVersionId()); + } catch (ClassCastException e) { + // if we fall through we have the correct type already in the create + } - return result.getPayload(); - } - -// -// public boolean delete(Class resourceClass, String id) { -// try { -// return utils.issueDeleteRequest(resourceAddress.resolveGetUriFromResourceClassAndId(resourceClass, id), proxy); -// } catch(Exception e) { -// throw new EFhirClientException("An error has occurred while trying to delete this resource", e); -// } -// -// } - -// -// public OperationOutcome create(Class resourceClass, T resource) { -// ResourceRequest resourceRequest = null; -// try { -// List
headers = null; -// resourceRequest = utils.issuePostRequest(resourceAddress.resolveGetUriFromResourceClass(resourceClass),utils.getResourceAsByteArray(resource, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, proxy); -// resourceRequest.addSuccessStatus(201); -// if(resourceRequest.isUnsuccessfulRequest()) { -// throw new EFhirClientException("Server responded with HTTP error code " + resourceRequest.getHttpStatus(), (OperationOutcome)resourceRequest.getPayload()); -// } -// } catch(Exception e) { -// handleException("An error has occurred while trying to create this resource", e); -// } -// OperationOutcome operationOutcome = null;; -// try { -// operationOutcome = (OperationOutcome)resourceRequest.getPayload(); -// ResourceAddress.ResourceVersionedIdentifier resVersionedIdentifier = -// ResourceAddress.parseCreateLocation(resourceRequest.getLocation()); -// OperationOutcomeIssueComponent issue = operationOutcome.addIssue(); -// issue.setSeverity(IssueSeverity.INFORMATION); -// issue.setUserData(ResourceAddress.ResourceVersionedIdentifier.class.toString(), -// resVersionedIdentifier); -// return operationOutcome; -// } catch(ClassCastException e) { -// // some server (e.g. grahams) returns the resource directly -// operationOutcome = new OperationOutcome(); -// OperationOutcomeIssueComponent issue = operationOutcome.addIssue(); -// issue.setSeverity(IssueSeverity.INFORMATION); -// issue.setUserData(ResourceRequest.class.toString(), -// resourceRequest.getPayload()); -// return operationOutcome; -// } -// } - -// -// public Bundle history(Calendar lastUpdate, Class resourceClass, String id) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForResourceId(resourceClass, id, lastUpdate, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history information for this resource", e); -// } -// return history; -// } - -// -// public Bundle history(Date lastUpdate, Class resourceClass, String id) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForResourceId(resourceClass, id, lastUpdate, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history information for this resource", e); -// } -// return history; -// } -// -// -// public Bundle history(Calendar lastUpdate, Class resourceClass) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForResourceType(resourceClass, lastUpdate, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history information for this resource type", e); -// } -// return history; -// } -// -// -// public Bundle history(Date lastUpdate, Class resourceClass) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForResourceType(resourceClass, lastUpdate, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history information for this resource type", e); -// } -// return history; -// } -// -// -// public Bundle history(Class resourceClass) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForResourceType(resourceClass, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history information for this resource type", e); -// } -// return history; -// } -// -// -// public Bundle history(Class resourceClass, String id) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForResourceId(resourceClass, id, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history information for this resource", e); -// } -// return history; -// } -// -// -// public Bundle history(Date lastUpdate) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForAllResources(lastUpdate, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history since last update",e); -// } -// return history; -// } -// -// -// public Bundle history(Calendar lastUpdate) { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForAllResources(lastUpdate, maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history since last update",e); -// } -// return history; -// } -// -// -// public Bundle history() { -// Bundle history = null; -// try { -// history = utils.issueGetFeedRequest(resourceAddress.resolveGetHistoryForAllResources(maxResultSetSize), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("An error has occurred while trying to retrieve history since last update",e); -// } -// return history; -// } -// -// -// public Bundle search(Class resourceClass, Map parameters) { -// Bundle searchResults = null; -// try { -// searchResults = utils.issueGetFeedRequest(resourceAddress.resolveSearchUri(resourceClass, parameters), getPreferredResourceFormat(), proxy); -// } catch (Exception e) { -// handleException("Error performing search with parameters " + parameters, e); -// } -// return searchResults; -// } -// -// -// public Bundle searchPost(Class resourceClass, T resource, Map parameters) { -// Bundle searchResults = null; -// try { -// searchResults = utils.issuePostFeedRequest(resourceAddress.resolveSearchUri(resourceClass, new HashMap()), parameters, "src", resource, getPreferredResourceFormat()); -// } catch (Exception e) { -// handleException("Error performing search with parameters " + parameters, e); -// } -// return searchResults; -// } - - - public Parameters operateType(Class resourceClass, String name, Parameters params) { - boolean complex = false; - for (ParametersParameterComponent p : params.getParameter()) - complex = complex || !(p.getValue() instanceof PrimitiveType); - Parameters searchResults = null; - String ps = ""; - try { - if (!complex) - for (ParametersParameterComponent p : params.getParameter()) - if (p.getValue() instanceof PrimitiveType) - ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue())+"&"; - ResourceRequest result; - if (complex) { - result = utils.issuePostRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps), utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), - "POST "+resourceClass.getName()+"/$"+name, TIMEOUT_OPERATION_LONG); - } else { - result = utils.issueGetResourceRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps), getPreferredResourceFormat(), "GET "+resourceClass.getName()+"/$"+name, TIMEOUT_OPERATION_LONG); - } - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addSuccessStatus(200);//Only one for now - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); - } - if (result.getPayload() instanceof Parameters) { - return (Parameters) result.getPayload(); - } else { - Parameters p_out = new Parameters(); - p_out.addParameter().setName("return").setResource(result.getPayload()); - return p_out; - } - } catch (Exception e) { - handleException("Error performing operation '"+name+"' with parameters " + ps, e); - } - return null; - } - - - public Bundle transaction(Bundle batch) { - Bundle transactionResult = null; - try { - transactionResult = utils.postBatchRequest(resourceAddress.getBaseServiceUri(), utils.getFeedAsByteArray(batch, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), "transaction", TIMEOUT_NORMAL+batch.getEntry().size()); - } catch (Exception e) { - handleException("An error occurred trying to process this transaction request", e); - } - return transactionResult; - } - - @SuppressWarnings("unchecked") - public OperationOutcome validate(Class resourceClass, T resource, String id) { - ResourceRequest result = null; - try { - result = utils.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id), utils.getResourceAsByteArray(resource, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), "POST "+resourceClass.getName()+(id != null ? "/"+id : "")+"/$validate", TIMEOUT_OPERATION_LONG); - result.addErrorStatus(400);//gone - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200);//OK - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); - } - } catch(Exception e) { - handleException("An error has occurred while trying to validate this resource", e); - } - return (OperationOutcome)result.getPayload(); - } - - /* change to meta operations - - public List getAllTags() { - TagListRequest result = null; - try { - result = utils.issueGetRequestForTagList(resourceAddress.resolveGetAllTags(), getPreferredResourceFormat(), null, proxy); - } catch (Exception e) { - handleException("An error has occurred while trying to retrieve all tags", e); - } - return result.getPayload(); - } - - - public List getAllTagsForResourceType(Class resourceClass) { - TagListRequest result = null; - try { - result = utils.issueGetRequestForTagList(resourceAddress.resolveGetAllTagsForResourceType(resourceClass), getPreferredResourceFormat(), null, proxy); - } catch (Exception e) { - handleException("An error has occurred while trying to retrieve tags for this resource type", e); - } - return result.getPayload(); - } - - - public List getTagsForReference(Class resource, String id) { - TagListRequest result = null; - try { - result = utils.issueGetRequestForTagList(resourceAddress.resolveGetTagsForReference(resource, id), getPreferredResourceFormat(), null, proxy); - } catch (Exception e) { - handleException("An error has occurred while trying to retrieve tags for this resource", e); - } - return result.getPayload(); - } - - - public List getTagsForResourceVersion(Class resource, String id, String versionId) { - TagListRequest result = null; - try { - result = utils.issueGetRequestForTagList(resourceAddress.resolveGetTagsForResourceVersion(resource, id, versionId), getPreferredResourceFormat(), null, proxy); - } catch (Exception e) { - handleException("An error has occurred while trying to retrieve tags for this resource version", e); - } - return result.getPayload(); - } - -// -// public boolean deleteTagsForReference(Class resourceClass, String id) { -// try { -// return utils.issueDeleteRequest(resourceAddress.resolveGetTagsForReference(resourceClass, id), proxy); -// } catch(Exception e) { -// handleException("An error has occurred while trying to retrieve tags for this resource version", e); -// throw new EFhirClientException("An error has occurred while trying to delete this resource", e); -// } -// -// } -// -// -// public boolean deleteTagsForResourceVersion(Class resourceClass, String id, List tags, String version) { -// try { -// return utils.issueDeleteRequest(resourceAddress.resolveGetTagsForResourceVersion(resourceClass, id, version), proxy); -// } catch(Exception e) { -// handleException("An error has occurred while trying to retrieve tags for this resource version", e); -// throw new EFhirClientException("An error has occurred while trying to delete this resource", e); -// } -// } - - - public List createTags(List tags, Class resourceClass, String id) { - TagListRequest request = null; - try { - request = utils.issuePostRequestForTagList(resourceAddress.resolveGetTagsForReference(resourceClass, id),utils.getTagListAsByteArray(tags, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, proxy); - request.addSuccessStatus(201); - request.addSuccessStatus(200); - if(request.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server responded with HTTP error code " + request.getHttpStatus()); - } - } catch(Exception e) { - handleException("An error has occurred while trying to set tags for this resource", e); - } - return request.getPayload(); - } - - - public List createTags(List tags, Class resourceClass, String id, String version) { - TagListRequest request = null; - try { - request = utils.issuePostRequestForTagList(resourceAddress.resolveGetTagsForResourceVersion(resourceClass, id, version),utils.getTagListAsByteArray(tags, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, proxy); - request.addSuccessStatus(201); - request.addSuccessStatus(200); - if(request.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server responded with HTTP error code " + request.getHttpStatus()); - } - } catch(Exception e) { - handleException("An error has occurred while trying to set the tags for this resource version", e); - } - return request.getPayload(); - } - - - public List deleteTags(List tags, Class resourceClass, String id, String version) { - TagListRequest request = null; - try { - request = utils.issuePostRequestForTagList(resourceAddress.resolveDeleteTagsForResourceVersion(resourceClass, id, version),utils.getTagListAsByteArray(tags, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, proxy); - request.addSuccessStatus(201); - request.addSuccessStatus(200); - if(request.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server responded with HTTP error code " + request.getHttpStatus()); - } - } catch(Exception e) { - handleException("An error has occurred while trying to delete the tags for this resource version", e); - } - return request.getPayload(); - } - */ - - /** - * Helper method to prevent nesting of previously thrown EFhirClientExceptions - * - * @param e - * @throws EFhirClientException - */ - protected void handleException(String message, Exception e) throws EFhirClientException { - if(e instanceof EFhirClientException) { - throw (EFhirClientException)e; - } else { - throw new EFhirClientException(message, e); - } - } - - /** - * Helper method to determine whether desired resource representation - * is Json or XML. - * - * @param format - * @return - */ - protected boolean isJson(String format) { - boolean isJson = false; - if(format.toLowerCase().contains("json")) { - isJson = true; - } - return isJson; - } - - public Bundle fetchFeed(String url) { - Bundle feed = null; - try { - feed = utils.issueGetFeedRequest(new URI(url), getPreferredResourceFormat()); - } catch (Exception e) { - handleException("An error has occurred while trying to retrieve history since last update",e); - } - return feed; + return result.getPayload(); } - + + public Parameters operateType(Class resourceClass, String name, Parameters params) { + boolean complex = false; + for (ParametersParameterComponent p : params.getParameter()) + complex = complex || !(p.getValue() instanceof PrimitiveType); + String ps = ""; + try { + if (!complex) + for (ParametersParameterComponent p : params.getParameter()) + if (p.getValue() instanceof PrimitiveType) + ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&"; + ResourceRequest result; + if (complex) { + result = client.issuePostRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps), ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), + "POST " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG); + } else { + result = client.issueGetResourceRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps), getPreferredResourceFormat(), "GET " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG); + } + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); + } + if (result.getPayload() instanceof Parameters) { + return (Parameters) result.getPayload(); + } else { + Parameters p_out = new Parameters(); + p_out.addParameter().setName("return").setResource(result.getPayload()); + return p_out; + } + } catch (Exception e) { + handleException("Error performing operation '" + name + "' with parameters " + ps, e); + } + return null; + } + + + public Bundle transaction(Bundle batch) { + Bundle transactionResult = null; + try { + transactionResult = client.postBatchRequest(resourceAddress.getBaseServiceUri(), ByteUtils.resourceToByteArray(batch, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), "transaction", TIMEOUT_NORMAL + batch.getEntry().size()); + } catch (Exception e) { + handleException("An error occurred trying to process this transaction request", e); + } + return transactionResult; + } + + @SuppressWarnings("unchecked") + public OperationOutcome validate(Class resourceClass, T resource, String id) { + ResourceRequest result = null; + try { + result = client.issuePostRequest(resourceAddress.resolveValidateUri(resourceClass, id), ByteUtils.resourceToByteArray(resource, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), "POST " + resourceClass.getName() + (id != null ? "/" + id : "") + "/$validate", TIMEOUT_OPERATION_LONG); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); + } + } catch (Exception e) { + handleException("An error has occurred while trying to validate this resource", e); + } + return (OperationOutcome) result.getPayload(); + } + + /** + * Helper method to prevent nesting of previously thrown EFhirClientExceptions + * + * @param e + * @throws EFhirClientException + */ + protected void handleException(String message, Exception e) throws EFhirClientException { + if (e instanceof EFhirClientException) { + throw (EFhirClientException) e; + } else { + throw new EFhirClientException(message, e); + } + } + + /** + * Helper method to determine whether desired resource representation + * is Json or XML. + * + * @param format + * @return + */ + protected boolean isJson(String format) { + boolean isJson = false; + if (format.toLowerCase().contains("json")) { + isJson = true; + } + return isJson; + } + + public Bundle fetchFeed(String url) { + Bundle feed = null; + try { + feed = client.issueGetFeedRequest(new URI(url), getPreferredResourceFormat()); + } catch (Exception e) { + handleException("An error has occurred while trying to retrieve history since last update", e); + } + return feed; + } + public ValueSet expandValueset(ValueSet source, Parameters expParams) { - List
headers = null; Parameters p = expParams == null ? new Parameters() : expParams.copy(); p.addParameter().setName("valueSet").setResource(source); - ResourceRequest result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"), - utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, "ValueSet/$expand?url="+source.getUrl(), TIMEOUT_OPERATION_EXPAND); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; + try { + result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"), + ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, "ValueSet/$expand?url=" + source.getUrl(), TIMEOUT_OPERATION_EXPAND); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } - return (ValueSet) result.getPayload(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return result == null ? null : (ValueSet) result.getPayload(); } - + public Parameters lookupCode(Map params) { - ResourceRequest result = utils.issueGetResourceRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup", params), getPreferredResourceFormat(), "CodeSystem/$lookup", TIMEOUT_NORMAL); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; + try { + result = client.issueGetResourceRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup", params), getPreferredResourceFormat(), "CodeSystem/$lookup", TIMEOUT_NORMAL); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } return (Parameters) result.getPayload(); } + public ValueSet expandValueset(ValueSet source, Parameters expParams, Map params) { - List
headers = null; Parameters p = expParams == null ? new Parameters() : expParams.copy(); p.addParameter().setName("valueSet").setResource(source); for (String n : params.keySet()) { p.addParameter().setName(n).setValue(new StringType(params.get(n))); } - ResourceRequest result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), - utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, "ValueSet/$expand?url="+source.getUrl(), TIMEOUT_OPERATION_EXPAND); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; + try { + result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), + ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, "ValueSet/$expand?url=" + source.getUrl(), TIMEOUT_OPERATION_EXPAND); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } - return (ValueSet) result.getPayload(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return result == null ? null : (ValueSet) result.getPayload(); } - -// public ValueSet expandValueset(ValueSet source, ExpansionProfile profile, Map params) { -// List
headers = null; -// ResourceRequest result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), -// utils.getResourceAsByteArray(source, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, proxy); -// result.addErrorStatus(410);//gone -// result.addErrorStatus(404);//unknown -// result.addErrorStatus(405); -// result.addErrorStatus(422);//Unprocessable Entity -// result.addSuccessStatus(200); -// result.addSuccessStatus(201); -// if(result.isUnsuccessfulRequest()) { -// throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); -// } -// return (ValueSet) result.getPayload(); -// } - - + public String getAddress() { return base; } @@ -769,79 +404,60 @@ public class FHIRToolingClient { public ConceptMap initializeClosure(String name) { Parameters params = new Parameters(); params.addParameter().setName("name").setValue(new StringType(name)); - List
headers = null; - ResourceRequest result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap()), - utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, "Closure?name="+name, TIMEOUT_NORMAL); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + ResourceRequest result = null; + try { + result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap()), + ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, "Closure?name=" + name, TIMEOUT_NORMAL); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } - return (ConceptMap) result.getPayload(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return result == null ? null : (ConceptMap) result.getPayload(); } public ConceptMap updateClosure(String name, Coding coding) { Parameters params = new Parameters(); params.addParameter().setName("name").setValue(new StringType(name)); params.addParameter().setName("concept").setValue(coding); - List
headers = null; - ResourceRequest result = utils.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap()), - utils.getResourceAsByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, "UpdateClosure?name="+name, TIMEOUT_OPERATION); - result.addErrorStatus(410);//gone - result.addErrorStatus(404);//unknown - result.addErrorStatus(405); - result.addErrorStatus(422);//Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if(result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); + org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; + try { + result = client.issuePostRequest(resourceAddress.resolveOperationUri(null, "closure", new HashMap()), + ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), null, "UpdateClosure?name=" + name, TIMEOUT_OPERATION); + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); } - return (ConceptMap) result.getPayload(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return result == null ? null : (ConceptMap) result.getPayload(); } - public int getTimeout() { - return utils.getTimeout(); + public long getTimeout() { + return client.getTimeout(); } - public void setTimeout(int timeout) { - utils.setTimeout(timeout); - } - - public String getUsername() { - return utils.getUsername(); - } - - public void setUsername(String username) { - utils.setUsername(username); - } - - public String getPassword() { - return utils.getPassword(); - } - - public void setPassword(String password) { - utils.setPassword(password); + public void setTimeout(long timeout) { + client.setTimeout(timeout); } public ToolingClientLogger getLogger() { - return utils.getLogger(); + return client.getLogger(); } public void setLogger(ToolingClientLogger logger) { - utils.setLogger(logger); + client.setLogger(logger); } public int getRetryCount() { - return utils.getRetryCount(); + return client.getRetryCount(); } public void setRetryCount(int retryCount) { - utils.setRetryCount(retryCount); + client.setRetryCount(retryCount); } -} \ No newline at end of file +} + diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceAddress.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceAddress.java index 19c946461..2085c5bb6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceAddress.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceAddress.java @@ -228,9 +228,6 @@ public class ResourceAddress { /** * For now, assume this type of location header structure. * Generalize later: http://hl7connect.healthintersections.com.au/svc/fhir/318/_history/1 - * - * @param serviceBase - * @param locationHeader */ public static ResourceAddress.ResourceVersionedIdentifier parseCreateLocation(String locationResponseHeader) { Pattern pattern = Pattern.compile(REGEX_ID_WITH_HISTORY); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceRequest.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceRequest.java deleted file mode 100644 index ca56224a9..000000000 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/ResourceRequest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.hl7.fhir.r5.utils.client; - - - - - -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -*/ - - -import java.util.ArrayList; -import java.util.List; - -import org.hl7.fhir.r5.model.Resource; - -public class ResourceRequest { - private T payload; - private int httpStatus = -1; - private String location; - private List successfulStatuses = new ArrayList(); - private List errorStatuses = new ArrayList(); - - public ResourceRequest(T payload, int httpStatus, List successfulStatuses, List errorStatuses, String location) { - this.payload = payload; - this.httpStatus = httpStatus; - if(successfulStatuses != null) { - this.successfulStatuses.addAll(successfulStatuses); - } - if(errorStatuses != null) { - this.errorStatuses.addAll(errorStatuses); - } - this.location = location; - } - - public ResourceRequest(T payload, int httpStatus, String location) { - this.payload = payload; - this.httpStatus = httpStatus; - this.location = location; - } - - public ResourceRequest(T payload, int httpStatus, int successfulStatus, String location) { - this.payload = payload; - this.httpStatus = httpStatus; - this.successfulStatuses.add(successfulStatus); - this.location = location; - } - - public int getHttpStatus() { - return httpStatus; - } - - public T getPayload() { - return payload; - } - - public T getReference() { - T payloadResource = null; - if(payload != null) { - payloadResource = payload; - } - return payloadResource; - } - - public boolean isSuccessfulRequest() { - return successfulStatuses.contains(httpStatus) && !errorStatuses.contains(httpStatus) && httpStatus > 0; - } - - public boolean isUnsuccessfulRequest() { - return !isSuccessfulRequest(); - } - - public void addSuccessStatus(int status) { - this.successfulStatuses.add(status); - } - - public void addErrorStatus(int status) { - this.errorStatuses.add(status); - } - - public String getLocation() { - return location; - } -} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ByteUtils.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ByteUtils.java new file mode 100644 index 000000000..7969c184b --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ByteUtils.java @@ -0,0 +1,69 @@ +package org.hl7.fhir.r5.utils.client.network; + +import org.hl7.fhir.r5.formats.IParser; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.formats.XmlParser; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.utils.client.EFhirClientException; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.util.Map; + +public class ByteUtils { + + public static byte[] resourceToByteArray(T resource, boolean pretty, boolean isJson) { + ByteArrayOutputStream baos = null; + byte[] byteArray = null; + try { + baos = new ByteArrayOutputStream(); + IParser parser = null; + if (isJson) { + parser = new JsonParser(); + } else { + parser = new XmlParser(); + } + parser.setOutputStyle(pretty ? IParser.OutputStyle.PRETTY : IParser.OutputStyle.NORMAL); + parser.compose(baos, resource); + baos.close(); + byteArray = baos.toByteArray(); + baos.close(); + } catch (Exception e) { + try { + baos.close(); + } catch (Exception ex) { + throw new EFhirClientException("Error closing output stream", ex); + } + throw new EFhirClientException("Error converting output stream to byte array", e); + } + return byteArray; + } + + public static byte[] encodeFormSubmission(Map parameters, String resourceName, Resource resource, String boundary) throws IOException { + ByteArrayOutputStream b = new ByteArrayOutputStream(); + OutputStreamWriter w = new OutputStreamWriter(b, StandardCharsets.UTF_8); + for (String name : parameters.keySet()) { + w.write("--"); + w.write(boundary); + w.write("\r\nContent-Disposition: form-data; name=\"" + name + "\"\r\n\r\n"); + w.write(parameters.get(name) + "\r\n"); + } + w.write("--"); + w.write(boundary); + w.write("\r\nContent-Disposition: form-data; name=\"" + resourceName + "\"\r\n\r\n"); + w.close(); + JsonParser json = new JsonParser(); + json.setOutputStyle(IParser.OutputStyle.NORMAL); + json.compose(b, resource); + b.close(); + w = new OutputStreamWriter(b, StandardCharsets.UTF_8); + w.write("\r\n--"); + w.write(boundary); + w.write("--"); + w.close(); + return b.toByteArray(); + } +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/Client.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/Client.java new file mode 100644 index 000000000..a41289663 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/Client.java @@ -0,0 +1,234 @@ +package org.hl7.fhir.r5.utils.client.network; + +import okhttp3.Headers; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.utils.client.EFhirClientException; +import org.hl7.fhir.utilities.ToolingClientLogger; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URLConnection; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class Client { + + public static final String DEFAULT_CHARSET = "UTF-8"; + private static final long DEFAULT_TIMEOUT = 5000; + private String username; + private String password; + private ToolingClientLogger logger; + private int retryCount; + private long timeout = DEFAULT_TIMEOUT; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public ToolingClientLogger getLogger() { + return logger; + } + + public void setLogger(ToolingClientLogger logger) { + this.logger = logger; + } + + public int getRetryCount() { + return retryCount; + } + + public void setRetryCount(int retryCount) { + this.retryCount = retryCount; + } + + public long getTimeout() { + return timeout; + } + + public void setTimeout(long timeout) { + this.timeout = timeout; + } + + public ResourceRequest issueOptionsRequest(URI optionsUri, + String resourceFormat, + String message, + long timeout) throws MalformedURLException { + Request.Builder request = new Request.Builder() + .method("OPTIONS", null) + .url(optionsUri.toURL()); + + return executeFhirRequest(request, resourceFormat, null, message, retryCount, timeout); + } + + public ResourceRequest issueGetResourceRequest(URI resourceUri, + String resourceFormat, + String message, + long timeout) throws MalformedURLException { + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()); + + return executeFhirRequest(request, resourceFormat, null, message, retryCount, timeout); + } + + public ResourceRequest issuePutRequest(URI resourceUri, + byte[] payload, + String resourceFormat, + String message, + long timeout) throws MalformedURLException { + return issuePutRequest(resourceUri, payload, resourceFormat, null, message, timeout); + } + + public ResourceRequest issuePutRequest(URI resourceUri, + byte[] payload, + String resourceFormat, + Headers headers, + String message, + long timeout) throws MalformedURLException { + if (payload == null) throw new EFhirClientException("PUT requests require a non-null payload"); + RequestBody body = RequestBody.create(payload); + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()) + .put(body); + + return executeFhirRequest(request, resourceFormat, headers, message, retryCount, timeout); + } + + public ResourceRequest issuePostRequest(URI resourceUri, + byte[] payload, + String resourceFormat, + String message, + long timeout) throws MalformedURLException { + return issuePostRequest(resourceUri, payload, resourceFormat, null, message, timeout); + } + + public ResourceRequest issuePostRequest(URI resourceUri, + byte[] payload, + String resourceFormat, + Headers headers, + String message, + long timeout) throws MalformedURLException { + if (payload == null) throw new EFhirClientException("POST requests require a non-null payload"); + RequestBody body = RequestBody.create(MediaType.parse(resourceFormat + ";charset=" + DEFAULT_CHARSET), payload); + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()) + .post(body); + + return executeFhirRequest(request, resourceFormat, headers, message, retryCount, timeout); + } + + public boolean issueDeleteRequest(URI resourceUri) throws MalformedURLException { + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()) + .delete(); + return executeFhirRequest(request, null, null, null, retryCount, timeout).isSuccessfulRequest(); + } + + public Bundle issueGetFeedRequest(URI resourceUri, String resourceFormat) throws MalformedURLException { + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()); + + return executeBundleRequest(request, resourceFormat, null, null, retryCount, timeout); + } + + public Bundle issuePostFeedRequest(URI resourceUri, + Map parameters, + String resourceName, + Resource resource, + String resourceFormat) throws IOException { + String boundary = "----WebKitFormBoundarykbMUo6H8QaUnYtRy"; + byte[] payload = ByteUtils.encodeFormSubmission(parameters, resourceName, resource, boundary); + RequestBody body = RequestBody.create(MediaType.parse(resourceFormat + ";charset=" + DEFAULT_CHARSET), payload); + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()) + .post(body); + + return executeBundleRequest(request, resourceFormat, null, null, retryCount, timeout); + } + + public Bundle postBatchRequest(URI resourceUri, + byte[] payload, + String resourceFormat, + String message, + int timeout) throws MalformedURLException { + if (payload == null) throw new EFhirClientException("POST requests require a non-null payload"); + RequestBody body = RequestBody.create(MediaType.parse(resourceFormat + ";charset=" + DEFAULT_CHARSET), payload); + Request.Builder request = new Request.Builder() + .url(resourceUri.toURL()) + .post(body); + + return executeBundleRequest(request, resourceFormat, null, message, retryCount, timeout); + } + + protected Bundle executeBundleRequest(Request.Builder request, + String resourceFormat, + Headers headers, + String message, + int retryCount, + long timeout) { + return new FhirRequestBuilder(request) + .withLogger(logger) + .withResourceFormat(resourceFormat) + .withRetryCount(retryCount) + .withMessage(message) + .withHeaders(headers == null ? new Headers.Builder().build() : headers) + .withTimeout(timeout, TimeUnit.MILLISECONDS) + .executeAsBatch(); + } + + protected ResourceRequest executeFhirRequest(Request.Builder request, + String resourceFormat, + Headers headers, + String message, + int retryCount, + long timeout) { + return new FhirRequestBuilder(request) + .withLogger(logger) + .withResourceFormat(resourceFormat) + .withRetryCount(retryCount) + .withMessage(message) + .withHeaders(headers == null ? new Headers.Builder().build() : headers) + .withTimeout(timeout, TimeUnit.MILLISECONDS) + .execute(); + } + + /** + * @deprecated It does not appear as though this method is actually being used. Will be removed in a future release + * unless a case is made to keep it. + */ + @Deprecated + public Calendar getLastModifiedResponseHeaderAsCalendarObject(URLConnection serverConnection) { + String dateTime = null; + try { + dateTime = serverConnection.getHeaderField("Last-Modified"); + SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", new Locale("en", "US")); + Date lastModifiedTimestamp = format.parse(dateTime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(lastModifiedTimestamp); + return calendar; + } catch (ParseException pe) { + throw new EFhirClientException("Error parsing Last-Modified response header " + dateTime, pe); + } + } +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilder.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilder.java new file mode 100644 index 000000000..46cadea91 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilder.java @@ -0,0 +1,339 @@ +package org.hl7.fhir.r5.utils.client.network; + +import kotlin.Pair; +import okhttp3.*; +import org.apache.commons.lang3.StringUtils; +import org.hl7.fhir.r5.formats.IParser; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.formats.XmlParser; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.OperationOutcome; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.utils.ResourceUtilities; +import org.hl7.fhir.r5.utils.client.EFhirClientException; +import org.hl7.fhir.r5.utils.client.ResourceFormat; +import org.hl7.fhir.utilities.ToolingClientLogger; + +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class FhirRequestBuilder { + + protected static final String HTTP_PROXY_USER = "http.proxyUser"; + protected static final String HTTP_PROXY_PASS = "http.proxyPassword"; + protected static final String HEADER_PROXY_AUTH = "Proxy-Authorization"; + protected static final String LOCATION_HEADER = "location"; + protected static final String CONTENT_LOCATION_HEADER = "content-location"; + protected static final String DEFAULT_CHARSET = "UTF-8"; + /** + * The singleton instance of the HttpClient, used for all requests. + */ + private static OkHttpClient okHttpClient; + private final Request.Builder httpRequest; + private String resourceFormat = null; + private Headers headers = null; + private String message = null; + private int retryCount = 1; + /** + * The timeout quantity. Used in combination with {@link FhirRequestBuilder#timeoutUnit}. + */ + private long timeout = 5000; + /** + * Time unit for {@link FhirRequestBuilder#timeout}. + */ + private TimeUnit timeoutUnit = TimeUnit.MILLISECONDS; + /** + * {@link ToolingClientLogger} for log output. + */ + private ToolingClientLogger logger = null; + + public FhirRequestBuilder(Request.Builder httpRequest) { + this.httpRequest = httpRequest; + } + + /** + * Adds necessary default headers, formatting headers, and any passed in {@link Headers} to the passed in + * {@link okhttp3.Request.Builder} + * + * @param request {@link okhttp3.Request.Builder} to add headers to. + * @param format Expected {@link Resource} format. + * @param headers Any additional {@link Headers} to add to the request. + */ + protected static void formatHeaders(Request.Builder request, String format, Headers headers) { + addDefaultHeaders(request); + if (format != null) addResourceFormatHeaders(request, format); + if (headers != null) addHeaders(request, headers); + } + + /** + * Adds necessary headers for all REST requests. + *
  • User-Agent : hapi-fhir-tooling-client
  • + *
  • Accept-Charset : {@link FhirRequestBuilder#DEFAULT_CHARSET}
  • + * + * @param request {@link Request.Builder} to add default headers to. + */ + protected static void addDefaultHeaders(Request.Builder request) { + request.addHeader("User-Agent", "hapi-fhir-tooling-client"); + request.addHeader("Accept-Charset", DEFAULT_CHARSET); + } + + /** + * Adds necessary headers for the given resource format provided. + * + * @param request {@link Request.Builder} to add default headers to. + */ + protected static void addResourceFormatHeaders(Request.Builder request, String format) { + request.addHeader("Accept", format); + request.addHeader("Content-Type", format + ";charset=" + DEFAULT_CHARSET); + } + + /** + * Iterates through the passed in {@link Headers} and adds them to the provided {@link Request.Builder}. + * + * @param request {@link Request.Builder} to add headers to. + * @param headers {@link Headers} to add to request. + */ + protected static void addHeaders(Request.Builder request, Headers headers) { + headers.forEach(header -> request.addHeader(header.getFirst(), header.getSecond())); + } + + /** + * Returns true if any of the {@link org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent} within the + * provided {@link OperationOutcome} have an {@link org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity} of + * {@link org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity#ERROR} or + * {@link org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity#FATAL} + * + * @param oo {@link OperationOutcome} to evaluate. + * @return {@link Boolean#TRUE} if an error exists. + */ + protected static boolean hasError(OperationOutcome oo) { + return (oo.getIssue().stream() + .anyMatch(issue -> issue.getSeverity() == OperationOutcome.IssueSeverity.ERROR + || issue.getSeverity() == OperationOutcome.IssueSeverity.FATAL)); + } + + /** + * Extracts the 'location' header from the passes in {@link Headers}. If no value for 'location' exists, the + * value for 'content-location' is returned. If neither header exists, we return null. + * + * @param headers {@link Headers} to evaluate + * @return {@link String} header value, or null if no location headers are set. + */ + protected static String getLocationHeader(Headers headers) { + Map> headerMap = headers.toMultimap(); + if (headerMap.containsKey(LOCATION_HEADER)) { + return headerMap.get(LOCATION_HEADER).get(0); + } else if (headerMap.containsKey(CONTENT_LOCATION_HEADER)) { + return headerMap.get(CONTENT_LOCATION_HEADER).get(0); + } else { + return null; + } + } + + /** + * We only ever want to have one copy of the HttpClient kicking around at any given time. If we need to make changes + * to any configuration, such as proxy settings, timeout, caches, etc, we can do a per-call configuration through + * the {@link OkHttpClient#newBuilder()} method. That will return a builder that shares the same connection pool, + * dispatcher, and configuration with the original client. + *

    + * The {@link OkHttpClient} uses the proxy auth properties set in the current system properties. The reason we don't + * set the proxy address and authentication explicitly, is due to the fact that this class is often used in conjunction + * with other http client tools which rely on the system.properties settings to determine proxy settings. It's easier + * to keep the method consistent across the board. ...for now. + * + * @return {@link OkHttpClient} instance + */ + protected OkHttpClient getHttpClient() { + if (okHttpClient == null) { + okHttpClient = new OkHttpClient(); + } + + Authenticator proxyAuthenticator = (route, response) -> { + String credential = Credentials.basic(System.getProperty(HTTP_PROXY_USER), System.getProperty(HTTP_PROXY_PASS)); + return response.request().newBuilder() + .header(HEADER_PROXY_AUTH, credential) + .build(); + }; + + return okHttpClient.newBuilder() + .addInterceptor(new RetryInterceptor(retryCount)) + .connectTimeout(timeout, timeoutUnit) + .writeTimeout(timeout, timeoutUnit) + .readTimeout(timeout, timeoutUnit) + .proxyAuthenticator(proxyAuthenticator) + .build(); + } + + public FhirRequestBuilder withResourceFormat(String resourceFormat) { + this.resourceFormat = resourceFormat; + return this; + } + + public FhirRequestBuilder withHeaders(Headers headers) { + this.headers = headers; + return this; + } + + public FhirRequestBuilder withMessage(String message) { + this.message = message; + return this; + } + + public FhirRequestBuilder withRetryCount(int retryCount) { + this.retryCount = retryCount; + return this; + } + + public FhirRequestBuilder withLogger(ToolingClientLogger logger) { + this.logger = logger; + return this; + } + + public FhirRequestBuilder withTimeout(long timeout, TimeUnit unit) { + this.timeout = timeout; + this.timeoutUnit = unit; + return this; + } + + protected Request buildRequest() { + return httpRequest.build(); + } + + public ResourceRequest execute() { + formatHeaders(httpRequest, resourceFormat, null); + + try { + Response response = getHttpClient().newCall(httpRequest.build()).execute(); + T resource = unmarshalReference(response, resourceFormat); + return new ResourceRequest(resource, response.code(), getLocationHeader(response.headers())); + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + public Bundle executeAsBatch() { + formatHeaders(httpRequest, resourceFormat, null); + + try { + Response response = getHttpClient().newCall(httpRequest.build()).execute(); + return unmarshalFeed(response, resourceFormat); + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + /** + * Unmarshalls a resource from the response stream. + */ + @SuppressWarnings("unchecked") + protected T unmarshalReference(Response response, String format) { + T resource = null; + OperationOutcome error = null; + + if (response.body() != null) { + try { + byte[] body = response.body().bytes(); + log(response.code(), response.headers(), body); + resource = (T) getParser(format).parse(body); + if (resource instanceof OperationOutcome && hasError((OperationOutcome) resource)) { + error = (OperationOutcome) resource; + } + } catch (IOException ioe) { + throw new EFhirClientException("Error reading Http Response: " + ioe.getMessage(), ioe); + } catch (Exception e) { + throw new EFhirClientException("Error parsing response message: " + e.getMessage(), e); + } + } + + if (error != null) { + throw new EFhirClientException("Error from server: " + ResourceUtilities.getErrorDescription(error), error); + } + + return resource; + } + + /** + * Unmarshalls Bundle from response stream. + */ + protected Bundle unmarshalFeed(Response response, String format) { + Bundle feed = null; + OperationOutcome error = null; + try { + byte[] body = response.body().bytes(); + log(response.code(), response.headers(), body); + String contentType = response.header("Content-Type"); + if (body != null) { + if (contentType.contains(ResourceFormat.RESOURCE_XML.getHeader()) || contentType.contains("text/xml+fhir")) { + Resource rf = getParser(format).parse(body); + if (rf instanceof Bundle) + feed = (Bundle) rf; + else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) { + error = (OperationOutcome) rf; + } else { + throw new EFhirClientException("Error reading server response: a resource was returned instead"); + } + } + } + } catch (IOException ioe) { + throw new EFhirClientException("Error reading Http Response", ioe); + } catch (Exception e) { + throw new EFhirClientException("Error parsing response message", e); + } + if (error != null) { + throw new EFhirClientException("Error from server: " + ResourceUtilities.getErrorDescription(error), error); + } + return feed; + } + + /** + * Returns the appropriate parser based on the format type passed in. Defaults to XML parser if a blank format is + * provided...because reasons. + *

    + * Currently supports only "json" and "xml" formats. + * + * @param format One of "json" or "xml". + * @return {@link JsonParser} or {@link XmlParser} + */ + protected IParser getParser(String format) { + if (StringUtils.isBlank(format)) { + format = ResourceFormat.RESOURCE_XML.getHeader(); + } + if (format.equalsIgnoreCase("json") || format.equalsIgnoreCase(ResourceFormat.RESOURCE_JSON.getHeader())) { + return new JsonParser(); + } else if (format.equalsIgnoreCase("xml") || format.equalsIgnoreCase(ResourceFormat.RESOURCE_XML.getHeader())) { + return new XmlParser(); + } else { + throw new EFhirClientException("Invalid format: " + format); + } + } + + /** + * Logs the given {@link Response}, using the current {@link ToolingClientLogger}. If the current + * {@link FhirRequestBuilder#logger} is null, no action is taken. + * + * @param responseCode HTTP response code + * @param responseHeaders {@link Headers} from response + * @param responseBody Byte array response + */ + protected void log(int responseCode, Headers responseHeaders, byte[] responseBody) { + if (logger != null) { + List headerList = new ArrayList<>(Collections.emptyList()); + Map> headerMap = responseHeaders.toMultimap(); + headerMap.keySet().forEach(key -> headerMap.get(key).forEach(value -> headerList.add(key + ":" + value))); + + try { + logger.logResponse(Integer.toString(responseCode), headerList, responseBody); + } catch (Exception e) { + System.out.println("Error parsing response body passed in to logger ->\n" + e.getLocalizedMessage()); + } + } else { + System.out.println("Call to log HTTP response with null ToolingClientLogger set... are you forgetting to " + + "initialize your logger?"); + } + } +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ResourceRequest.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ResourceRequest.java new file mode 100644 index 000000000..7c6abdaf6 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/ResourceRequest.java @@ -0,0 +1,71 @@ +package org.hl7.fhir.r5.utils.client.network; + +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +import org.hl7.fhir.r5.model.Resource; + +public class ResourceRequest { + private T payload; + private int httpStatus = -1; + private String location; + + public ResourceRequest(T payload, int httpStatus, String location) { + this.payload = payload; + this.httpStatus = httpStatus; + this.location = location; + } + + public int getHttpStatus() { + return httpStatus; + } + + public T getPayload() { + return payload; + } + + public T getReference() { + T payloadResource = null; + if (payload != null) { + payloadResource = payload; + } + return payloadResource; + } + + public boolean isSuccessfulRequest() { + return this.httpStatus / 100 == 2; + } + + public boolean isUnsuccessfulRequest() { + return !isSuccessfulRequest(); + } + + public String getLocation() { + return location; + } +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/RetryInterceptor.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/RetryInterceptor.java new file mode 100644 index 000000000..5e5d37871 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/network/RetryInterceptor.java @@ -0,0 +1,63 @@ +package org.hl7.fhir.r5.utils.client.network; + +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * An {@link Interceptor} for {@link okhttp3.OkHttpClient} that controls the number of times we retry a to execute a + * given request, before reporting a failure. This includes unsuccessful return codes and timeouts. + */ +public class RetryInterceptor implements Interceptor { + + // Delay between retying failed requests, in millis + private final long RETRY_TIME = 2000; + + // Maximum number of times to retry the request before failing + private final int maxRetry; + + // Internal counter for tracking the number of times we've tried this request + private int retryCounter = 0; + + public RetryInterceptor(int maxRetry) { + this.maxRetry = maxRetry; + } + + @Override + public @NotNull Response intercept(Interceptor.Chain chain) throws IOException { + Request request = chain.request(); + Response response = null; + + do { + try { + // If we are retrying a failed request that failed due to a bad response from the server, we must close it first + if (response != null) { + System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code()) + + "> from url -> " + chain.request().url() + "."); + response.close(); + } + System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url()); + response = chain.proceed(request); + } catch (IOException e) { + try { + // Include a small break in between requests. + Thread.sleep(RETRY_TIME); + } catch (InterruptedException e1) { + System.out.println(chain.request().method() + " to url -> " + chain.request().url() + " interrupted on try <" + retryCounter + ">"); + } + } finally { + retryCounter++; + } + } while ((response == null || !response.isSuccessful()) && (retryCounter <= maxRetry + 1)); + + /* + * if something has gone wrong, and we are unable to complete the request, we still need to initialize the return + * response so we don't get a null pointer exception. + */ + return response != null ? response : chain.proceed(request); + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java new file mode 100644 index 000000000..01a13a870 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java @@ -0,0 +1,146 @@ +package org.hl7.fhir.r5.utils.client.network; + +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.model.*; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +class ClientTest { + + private static final long TIMEOUT = 5000; + + private MockWebServer server; + private HttpUrl serverUrl; + private Client client; + + private Address address = new Address() + .setCity("Toronto") + .setState("Ontario") + .setCountry("Canada"); + private HumanName humanName = new HumanName() + .addGiven("Mark") + .setFamily("Iantorno"); + private Patient patient = new Patient() + .addName(humanName) + .addAddress(address) + .setGender(Enumerations.AdministrativeGender.MALE); + + @BeforeEach + void setup() { + setupMockServer(); + client = new Client(); + } + + void setupMockServer() { + server = new MockWebServer(); + serverUrl = server.url("/v1/endpoint"); + } + + byte[] generateResourceBytes(Resource resource) throws IOException { + return new JsonParser().composeBytes(resource); + } + + @Test + @DisplayName("GET request, happy path.") + void test_get_happy_path() throws IOException, URISyntaxException { + server.enqueue( + new MockResponse() + .setBody(new String(generateResourceBytes(patient))) + ); + ResourceRequest resourceRequest = client.issueGetResourceRequest(new URI(serverUrl.toString()), + "json", null, TIMEOUT); + Assertions.assertTrue(resourceRequest.isSuccessfulRequest()); + Assertions.assertTrue(patient.equalsDeep(resourceRequest.getPayload()), + "GET request returned resource does not match expected."); + } + + @Test + @DisplayName("GET request, test client retries after timeout failure.") + void test_get_retries_with_timeout() throws IOException, URISyntaxException { + int failedAttempts = new Random().nextInt(5) + 1; + System.out.println("Simulating <" + failedAttempts + "> failed connections (timeouts) before success."); + for (int i = 0; i < failedAttempts; i++) { + server.enqueue( + new MockResponse() + .setHeadersDelay(TIMEOUT * 10, TimeUnit.MILLISECONDS) + .setBody(new String(generateResourceBytes(patient))) + ); + } + server.enqueue(new MockResponse().setBody(new String(generateResourceBytes(patient)))); + client.setRetryCount(failedAttempts + 1); + + ResourceRequest resourceRequest = client.issueGetResourceRequest(new URI(serverUrl.toString()), + "json", null, TIMEOUT); + Assertions.assertTrue(resourceRequest.isSuccessfulRequest()); + Assertions.assertTrue(patient.equalsDeep(resourceRequest.getPayload()), + "GET request returned resource does not match expected."); + } + + @Test + @DisplayName("GET request, test client retries after bad response.") + void test_get_retries_with_unsuccessful_response() throws IOException, URISyntaxException { + int failedAttempts = new Random().nextInt(5) + 1; + System.out.println("Simulating <" + failedAttempts + "> failed connections (bad response codes) before success."); + for (int i = 0; i < failedAttempts; i++) { + server.enqueue( + new MockResponse() + .setResponseCode(400 + i) + .setBody(new String(generateResourceBytes(patient))) + ); + } + server.enqueue(new MockResponse().setBody(new String(generateResourceBytes(patient)))); + client.setRetryCount(failedAttempts + 1); + + ResourceRequest resourceRequest = client.issueGetResourceRequest(new URI(serverUrl.toString()), + "json", null, TIMEOUT); + Assertions.assertTrue(resourceRequest.isSuccessfulRequest()); + Assertions.assertTrue(patient.equalsDeep(resourceRequest.getPayload()), + "GET request returned resource does not match expected."); + } + + @Test + @DisplayName("PUT request, test payload received by server matches sent.") + void test_put() throws IOException, URISyntaxException, InterruptedException { + byte[] payload = ByteUtils.resourceToByteArray(patient, true, false); + // Mock server response of 200, with the same resource payload returned that we included in the PUT request + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody(new String(payload)) + ); + + ResourceRequest request = client.issuePutRequest(new URI(serverUrl.toString()), payload, + "xml", null, TIMEOUT); + RecordedRequest recordedRequest = server.takeRequest(); + Assertions.assertArrayEquals(payload, recordedRequest.getBody().readByteArray(), + "PUT request payload does not match send data."); + } + + @Test + @DisplayName("POST request, test payload received by server matches sent.") + void test_post() throws IOException, URISyntaxException, InterruptedException { + byte[] payload = ByteUtils.resourceToByteArray(patient, true, false); + // Mock server response of 200, with the same resource payload returned that we included in the PUT request + server.enqueue( + new MockResponse() + .setResponseCode(200) + .setBody(new String(payload)) + ); + + ResourceRequest request = client.issuePostRequest(new URI(serverUrl.toString()), payload, + "xml", null, TIMEOUT); + RecordedRequest recordedRequest = server.takeRequest(); + Assertions.assertArrayEquals(payload, recordedRequest.getBody().readByteArray(), + "POST request payload does not match send data."); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java new file mode 100644 index 000000000..24cf3b21b --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java @@ -0,0 +1,147 @@ +package org.hl7.fhir.r5.utils.client.network; + +import okhttp3.Headers; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import org.hl7.fhir.r5.model.OperationOutcome; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class FhirRequestBuilderTest { + + @Test + @DisplayName("Test default headers are added correctly.") + void addDefaultHeaders() { + Request.Builder request = new Request.Builder().url("http://www.google.com"); + FhirRequestBuilder.addDefaultHeaders(request); + + Map> headersMap = request.build().headers().toMultimap(); + Assertions.assertNotNull(headersMap.get("User-Agent"), "User-Agent header null."); + Assertions.assertEquals("hapi-fhir-tooling-client", headersMap.get("User-Agent").get(0), + "User-Agent header not populated with expected value \"hapi-fhir-tooling-client\"."); + + Assertions.assertNotNull(headersMap.get("Accept-Charset"), "Accept-Charset header null."); + Assertions.assertEquals(FhirRequestBuilder.DEFAULT_CHARSET, headersMap.get("Accept-Charset").get(0), + "Accept-Charset header not populated with expected value " + FhirRequestBuilder.DEFAULT_CHARSET); + } + + @Test + @DisplayName("Test resource format headers are added correctly.") + void addResourceFormatHeaders() { + String testFormat = "yaml"; + Request.Builder request = new Request.Builder().url("http://www.google.com"); + FhirRequestBuilder.addResourceFormatHeaders(request, testFormat); + + Map> headersMap = request.build().headers().toMultimap(); + Assertions.assertNotNull(headersMap.get("Accept"), "Accept header null."); + Assertions.assertEquals(testFormat, headersMap.get("Accept").get(0), + "Accept header not populated with expected value " + testFormat + "."); + + Assertions.assertNotNull(headersMap.get("Content-Type"), "Content-Type header null."); + Assertions.assertEquals(testFormat + ";charset=" + FhirRequestBuilder.DEFAULT_CHARSET, headersMap.get("Content-Type").get(0), + "Content-Type header not populated with expected value \"" + testFormat + ";charset=" + FhirRequestBuilder.DEFAULT_CHARSET + "\"."); + } + + @Test + @DisplayName("Test a list of provided headers are added correctly.") + void addHeaders() { + String headerName1 = "headerName1"; + String headerValue1 = "headerValue1"; + String headerName2 = "headerName2"; + String headerValue2 = "headerValue2"; + + Headers headers = new Headers.Builder() + .add(headerName1, headerValue1) + .add(headerName2, headerValue2) + .build(); + + Request.Builder request = new Request.Builder().url("http://www.google.com"); + FhirRequestBuilder.addHeaders(request, headers); + + Map> headersMap = request.build().headers().toMultimap(); + Assertions.assertNotNull(headersMap.get(headerName1), headerName1 + " header null."); + Assertions.assertEquals(headerValue1, headersMap.get(headerName1).get(0), + headerName1 + " header not populated with expected value " + headerValue1 + "."); + Assertions.assertNotNull(headersMap.get(headerName2), headerName2 + " header null."); + Assertions.assertEquals(headerValue2, headersMap.get(headerName2).get(0), + headerName2 + " header not populated with expected value " + headerValue2 + "."); + } + + @Test + @DisplayName("Test that FATAL issue severity triggers error.") + void hasErrorTestFatal() { + OperationOutcome outcome = new OperationOutcome(); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.INFORMATION)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.NULL)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.WARNING)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.FATAL)); + Assertions.assertTrue(FhirRequestBuilder.hasError(outcome), "Error check not triggered for FATAL issue severity."); + } + + @Test + @DisplayName("Test that ERROR issue severity triggers error.") + void hasErrorTestError() { + OperationOutcome outcome = new OperationOutcome(); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.INFORMATION)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.NULL)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.WARNING)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.ERROR)); + Assertions.assertTrue(FhirRequestBuilder.hasError(outcome), "Error check not triggered for ERROR issue severity."); + } + + @Test + @DisplayName("Test that no FATAL or ERROR issue severity does not trigger error.") + void hasErrorTestNoErrors() { + OperationOutcome outcome = new OperationOutcome(); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.INFORMATION)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.NULL)); + outcome.addIssue(new OperationOutcome.OperationOutcomeIssueComponent().setSeverity(OperationOutcome.IssueSeverity.WARNING)); + Assertions.assertFalse(FhirRequestBuilder.hasError(outcome), "Error check triggered unexpectedly."); + } + + @Test + @DisplayName("Test that getLocationHeader returns header for 'location'.") + void getLocationHeaderWhenOnlyLocationIsSet() { + final String expectedLocationHeader = "location_header_value"; + Headers headers = new Headers.Builder() + .add(FhirRequestBuilder.LOCATION_HEADER, expectedLocationHeader) + .build(); + Assertions.assertEquals(expectedLocationHeader, FhirRequestBuilder.getLocationHeader(headers)); + } + + @Test + @DisplayName("Test that getLocationHeader returns header for 'content-location'.") + void getLocationHeaderWhenOnlyContentLocationIsSet() { + final String expectedContentLocationHeader = "content_location_header_value"; + Headers headers = new Headers.Builder() + .add(FhirRequestBuilder.CONTENT_LOCATION_HEADER, expectedContentLocationHeader) + .build(); + Assertions.assertEquals(expectedContentLocationHeader, FhirRequestBuilder.getLocationHeader(headers)); + } + + @Test + @DisplayName("Test that getLocationHeader returns 'location' header when both 'location' and 'content-location' are set.") + void getLocationHeaderWhenLocationAndContentLocationAreSet() { + final String expectedLocationHeader = "location_header_value"; + final String expectedContentLocationHeader = "content_location_header_value"; + Headers headers = new Headers.Builder() + .add(FhirRequestBuilder.LOCATION_HEADER, expectedLocationHeader) + .add(FhirRequestBuilder.CONTENT_LOCATION_HEADER, expectedContentLocationHeader) + .build(); + Assertions.assertEquals(expectedLocationHeader, FhirRequestBuilder.getLocationHeader(headers)); + } + + @Test + @DisplayName("Test that getLocationHeader returns null when no location available.") + void getLocationHeaderWhenNoLocationSet() { + Headers headers = new Headers.Builder() + .build(); + Assertions.assertNull(FhirRequestBuilder.getLocationHeader(headers)); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java index 45dd6f34b..9a59e85c7 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java @@ -68,6 +68,11 @@ import org.hl7.fhir.validation.cli.services.ValidationService; import org.hl7.fhir.validation.cli.utils.*; import java.io.File; +import java.net.Authenticator; +import java.net.PasswordAuthentication; +import java.net.URL; +import java.net.URLConnection; +import java.util.Base64; /** * A executable class that will validate one or more FHIR resources against @@ -86,6 +91,11 @@ public class ValidatorCli { public static final String HTTP_PROXY_HOST = "http.proxyHost"; public static final String HTTP_PROXY_PORT = "http.proxyPort"; + public static final String HTTP_PROXY_USER = "http.proxyUser"; + public static final String HTTP_PROXY_PASS = "http.proxyPassword"; + public static final String JAVA_DISABLED_TUNNELING_SCHEMES = "jdk.http.auth.tunneling.disabledSchemes"; + public static final String JAVA_DISABLED_PROXY_SCHEMES = "jdk.http.auth.proxying.disabledSchemes"; + public static final String JAVA_USE_SYSTEM_PROXIES = "java.net.useSystemProxies"; public static void main(String[] args) throws Exception { TimeTracker tt = new TimeTracker(); @@ -95,11 +105,45 @@ public class ValidatorCli { Display.displaySystemInfo(); if (Params.hasParam(args, Params.PROXY)) { - String[] p = Params.getParam(args, Params.PROXY).split("\\:"); + assert Params.getParam(args, Params.PROXY) != null : "PROXY arg passed in was NULL"; + String[] p = Params.getParam(args, Params.PROXY).split(":"); System.setProperty(HTTP_PROXY_HOST, p[0]); System.setProperty(HTTP_PROXY_PORT, p[1]); } + if (Params.hasParam(args, Params.PROXY_AUTH)) { + assert Params.getParam(args, Params.PROXY) != null : "Cannot set PROXY_AUTH without setting PROXY..."; + assert Params.getParam(args, Params.PROXY_AUTH) != null : "PROXY_AUTH arg passed in was NULL..."; + String[] p = Params.getParam(args, Params.PROXY_AUTH).split(":"); + String authUser = p[0]; + String authPass = p[1]; + + /* + * For authentication, use java.net.Authenticator to set proxy's configuration and set the system properties + * http.proxyUser and http.proxyPassword + */ + Authenticator.setDefault( + new Authenticator() { + @Override + public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(authUser, authPass.toCharArray()); + } + } + ); + + System.setProperty(HTTP_PROXY_USER, authUser); + System.setProperty(HTTP_PROXY_PASS, authPass); + System.setProperty(JAVA_USE_SYSTEM_PROXIES, "true"); + + /* + * For Java 1.8 and higher you must set + * -Djdk.http.auth.tunneling.disabledSchemes= + * to make proxies with Basic Authorization working with https along with Authenticator + */ + System.setProperty(JAVA_DISABLED_TUNNELING_SCHEMES, ""); + System.setProperty(JAVA_DISABLED_PROXY_SCHEMES, ""); + } + CliContext cliContext = Params.loadCliContext(args); if (Params.hasParam(args, Params.TEST)) { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java index 51fdfc99d..fcb40d1f6 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java @@ -1,5 +1,6 @@ package org.hl7.fhir.validation.cli.utils; +import org.apache.http.auth.AUTH; import org.hl7.fhir.r5.utils.IResourceValidator.BundleValidationRule; import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.validation.cli.model.CliContext; @@ -14,6 +15,7 @@ public class Params { public static final String OUTPUT = "-output"; public static final String HTML_OUTPUT = "-html-output"; public static final String PROXY = "-proxy"; + public static final String PROXY_AUTH = "-auth"; public static final String PROFILE = "-profile"; public static final String BUNDLE = "-bundle"; public static final String QUESTIONNAIRE = "-questionnaire"; @@ -101,6 +103,8 @@ public class Params { cliContext.setHtmlOutput(args[++i]); } else if (args[i].equals(PROXY)) { i++; // ignore next parameter + } else if (args[i].equals(PROXY_AUTH)) { + i++; } else if (args[i].equals(PROFILE)) { String p = null; if (i + 1 == args.length) { From d45f8ae1a506d6341e23ef15b99d3ddeb9ea23c2 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Tue, 24 Nov 2020 09:28:05 -0500 Subject: [PATCH 2/6] Fix for issue #373, and all other convertor methods that contain this same error. (#379) --- .../convertors/VersionConvertor_10_30.java | 3143 +++-- .../convertors/VersionConvertor_10_40.java | 6400 +++++----- .../convertors/VersionConvertor_10_50.java | 6391 +++++----- .../convertors/VersionConvertor_14_30.java | 5420 ++++---- .../convertors/VersionConvertor_14_40.java | 5777 ++++----- .../convertors/VersionConvertor_14_50.java | 5780 ++++----- .../convertors/VersionConvertor_30_40.java | 9850 +++++++-------- .../convertors/VersionConvertor_30_50.java | 10438 ++++++++-------- .../convertors/VersionConvertor_40_50.java | 8342 ++++++------ .../AdministrativeGender10_30Test.java | 27 + .../resources/administrative_gender_null.json | 94 + 11 files changed, 28970 insertions(+), 32692 deletions(-) create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AdministrativeGender10_30Test.java create mode 100644 org.hl7.fhir.convertors/src/test/resources/administrative_gender_null.json diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java index 6c1efb085..0d79d3fde 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java @@ -18,8 +18,6 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; - - /* Copyright (c) 2011+, HL7, Inc. All rights reserved. @@ -46,10 +44,9 @@ import java.util.stream.Collectors; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -public class VersionConvertor_10_30 { +public class VersionConvertor_10_30 { public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.dstu3.model.Element tgt) throws FHIRException { tgt.setId(src.getId()); for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { @@ -300,1539 +297,1335 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); return tgt; } public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); return tgt; } public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); return tgt; } public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); tgt.setDiv(src.getDiv()); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasSizeElement()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasSizeElement()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHashElement()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasSizeElement()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasSizeElement()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHashElement()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); return tgt; } public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); copyElement(src, tgt); for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); return tgt; } public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); copyElement(src, tgt); for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); return tgt; } public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); + if (src.hasStartElement()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) tgt.setEndElement(convertDateTime(src.getEndElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); + if (src.hasStartElement()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) tgt.setEndElement(convertDateTime(src.getEndElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); return tgt; } public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); return tgt; } public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); return tgt; } public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); return tgt; } public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); return tgt; } public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); return tgt; } public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); copyElement(src, tgt); for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasBlobElement()) - tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasBlobElement()) tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); copyElement(src, tgt); for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasBlobElement()) - tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasBlobElement()) tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasCityElement()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; } public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasCityElement()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; } public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRankElement()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRankElement()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_30::convertPropertyRepresentation) - .collect(Collectors.toList())); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_10_30::convertPropertyRepresentation).collect(Collectors.toList())); if (src.hasName()) { - if (slicePaths.contains(src.getPath())) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasNameElement()) - tgt.setIdElement(convertString(src.getNameElement())); + if (slicePaths.contains(src.getPath())) tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasNameElement()) tgt.setIdElement(convertString(src.getNameElement())); } - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasNameReference()) - tgt.setContentReference("#" + src.getNameReference()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasNameReference()) tgt.setContentReference("#" + src.getNameReference()); for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertElementDefinitionTypeComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); if (src.hasMeaningWhenMissing()) tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_30::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - else - tgt.setNameElement(convertString(src.getIdElement())); - if (src.hasLabelElement()) - tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_10_30::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setNameElement(convertString(src.getSliceNameElement())); + else tgt.setNameElement(convertString(src.getIdElement())); + if (src.hasLabelElement()) tgt.setLabelElement(convertString(src.getLabelElement())); for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShortElement()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinitionElement()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasCommentElement()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShortElement()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinitionElement()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasCommentElement()) tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setNameReference(src.getContentReference().substring(1)); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setNameReference(src.getContentReference().substring(1)); for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertElementDefinitionTypeComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); if (src.hasMeaningWhenMissingElement()) tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExampleFirstRep().getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLengthElement()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.setExample(convertType(src.getExampleFirstRep().getValue())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLengthElement()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupportElement()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifierElement()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsSummaryElement()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + if (src.hasMustSupportElement()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifierElement()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsSummaryElement()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); copyElement(src, tgt); for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); copyElement(src, tgt); for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); copyElement(src, tgt); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCodeToUri(src.getCodeElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCodeToUri(src.getCodeElement())); for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) - if (src.hasTarget()) - tgt.setTargetProfile(t.getValueAsString()); - else - tgt.setProfile(t.getValue()); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_10_30::convertAggregationMode) - .collect(Collectors.toList())); + if (src.hasTarget()) tgt.setTargetProfile(t.getValueAsString()); + else tgt.setProfile(t.getValue()); + tgt.setAggregation(src.getAggregation().stream().map(VersionConvertor_10_30::convertAggregationMode).collect(Collectors.toList())); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent convertElementDefinitionTypeComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); copyElement(src, tgt); - if (src.hasCodeElement()) - tgt.setCodeElement(convertUriToCode(src.getCodeElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertUriToCode(src.getCodeElement())); if (src.hasTarget()) { - if (src.hasTargetProfile()) - tgt.addProfile(src.getTargetProfile()); - } else if (src.hasProfile()) - tgt.addProfile(src.getProfile()); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_10_30::convertAggregationMode) - .collect(Collectors.toList())); + if (src.hasTargetProfile()) tgt.addProfile(src.getTargetProfile()); + } else if (src.hasProfile()) tgt.addProfile(src.getProfile()); + tgt.setAggregation(src.getAggregation().stream().map(VersionConvertor_10_30::convertAggregationMode).collect(Collectors.toList())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); if (src.hasExpression()) ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSet(convertType(src.getValueSet())); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) tgt.setValueSet(convertType(src.getValueSet())); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSet(convertType(src.getValueSet())); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) tgt.setValueSet(convertType(src.getValueSet())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); return tgt; } public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); return tgt; } public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; } public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.addFamily(src.getFamily()); for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + if (src.hasVersionIdElement()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); @@ -1840,14 +1633,11 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + if (src.hasVersionIdElement()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); @@ -1855,487 +1645,397 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); copyElement(src, tgt); for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); return tgt; } public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); copyElement(src, tgt); for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); return tgt; } public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCountElement()) - tgt.setCountElement(convertInteger(src.getCountElement())); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnits()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); - if (src.hasFrequencyElement()) - tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); - if (src.hasFrequencyMaxElement()) - tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnits()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCountElement()) tgt.setCountElement(convertInteger(src.getCountElement())); + if (src.hasDurationElement()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnits()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); + if (src.hasFrequencyElement()) tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); + if (src.hasFrequencyMaxElement()) tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); return tgt; } public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCountElement()) - tgt.setCountElement(convertInteger(src.getCountElement())); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequencyElement()) - tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); - if (src.hasFrequencyMaxElement()) - tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCountElement()) tgt.setCountElement(convertInteger(src.getCountElement())); + if (src.hasDurationElement()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequencyElement()) tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); + if (src.hasFrequencyMaxElement()) tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); return tgt; } public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) @@ -2348,8 +2048,7 @@ public class VersionConvertor_10_30 { return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IdType) - return convertId((org.hl7.fhir.dstu2.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IdType) return convertId((org.hl7.fhir.dstu2.model.IdType) src); if (src instanceof org.hl7.fhir.dstu2.model.InstantType) return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) @@ -2360,16 +2059,14 @@ public class VersionConvertor_10_30 { return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2.model.OidType) - return convertOid((org.hl7.fhir.dstu2.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.OidType) return convertOid((org.hl7.fhir.dstu2.model.OidType) src); if (src instanceof org.hl7.fhir.dstu2.model.StringType) return convertString((org.hl7.fhir.dstu2.model.StringType) src); if (src instanceof org.hl7.fhir.dstu2.model.TimeType) return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); if (src instanceof org.hl7.fhir.dstu2.model.UuidType) return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UriType) - return convertUri((org.hl7.fhir.dstu2.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UriType) return convertUri((org.hl7.fhir.dstu2.model.UriType) src); if (src instanceof org.hl7.fhir.dstu2.model.Extension) return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); if (src instanceof org.hl7.fhir.dstu2.model.Narrative) @@ -2380,30 +2077,23 @@ public class VersionConvertor_10_30 { return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2.model.Coding) - return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2.model.Coding) return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); if (src instanceof org.hl7.fhir.dstu2.model.Identifier) return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2.model.Period) - return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2.model.Age) - return convertAge((org.hl7.fhir.dstu2.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2.model.Count) - return convertCount((org.hl7.fhir.dstu2.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2.model.Period) return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2.model.Age) return convertAge((org.hl7.fhir.dstu2.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2.model.Count) return convertCount((org.hl7.fhir.dstu2.model.Count) src); if (src instanceof org.hl7.fhir.dstu2.model.Distance) return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); if (src instanceof org.hl7.fhir.dstu2.model.Duration) return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2.model.Money) - return convertMoney((org.hl7.fhir.dstu2.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2.model.Money) return convertMoney((org.hl7.fhir.dstu2.model.Money) src); if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); if (src instanceof org.hl7.fhir.dstu2.model.Quantity) return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2.model.Range) - return convertRange((org.hl7.fhir.dstu2.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2.model.Range) return convertRange((org.hl7.fhir.dstu2.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2.model.Ratio) return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); if (src instanceof org.hl7.fhir.dstu2.model.Reference) return convertReference((org.hl7.fhir.dstu2.model.Reference) src); if (src instanceof org.hl7.fhir.dstu2.model.SampledData) @@ -2418,16 +2108,13 @@ public class VersionConvertor_10_30 { return convertElementDefinition((org.hl7.fhir.dstu2.model.ElementDefinition) src, new ArrayList()); if (src instanceof org.hl7.fhir.dstu2.model.HumanName) return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2.model.Meta) - return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2.model.Timing) - return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); + if (src instanceof org.hl7.fhir.dstu2.model.Meta) return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2.model.Timing) return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); throw new FHIRException("Unknown type " + src.fhirType()); } public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) @@ -2440,8 +2127,7 @@ public class VersionConvertor_10_30 { return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IdType) - return convertId((org.hl7.fhir.dstu3.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IdType) return convertId((org.hl7.fhir.dstu3.model.IdType) src); if (src instanceof org.hl7.fhir.dstu3.model.InstantType) return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) @@ -2452,16 +2138,14 @@ public class VersionConvertor_10_30 { return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu3.model.OidType) - return convertOid((org.hl7.fhir.dstu3.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.OidType) return convertOid((org.hl7.fhir.dstu3.model.OidType) src); if (src instanceof org.hl7.fhir.dstu3.model.StringType) return convertString((org.hl7.fhir.dstu3.model.StringType) src); if (src instanceof org.hl7.fhir.dstu3.model.TimeType) return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); if (src instanceof org.hl7.fhir.dstu3.model.UuidType) return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UriType) - return convertUri((org.hl7.fhir.dstu3.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UriType) return convertUri((org.hl7.fhir.dstu3.model.UriType) src); if (src instanceof org.hl7.fhir.dstu3.model.Extension) return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); if (src instanceof org.hl7.fhir.dstu3.model.Narrative) @@ -2472,30 +2156,23 @@ public class VersionConvertor_10_30 { return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu3.model.Coding) - return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu3.model.Coding) return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); if (src instanceof org.hl7.fhir.dstu3.model.Identifier) return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu3.model.Period) - return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); - if (src instanceof org.hl7.fhir.dstu3.model.Age) - return convertAge((org.hl7.fhir.dstu3.model.Age) src); - if (src instanceof org.hl7.fhir.dstu3.model.Count) - return convertCount((org.hl7.fhir.dstu3.model.Count) src); + if (src instanceof org.hl7.fhir.dstu3.model.Period) return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); + if (src instanceof org.hl7.fhir.dstu3.model.Age) return convertAge((org.hl7.fhir.dstu3.model.Age) src); + if (src instanceof org.hl7.fhir.dstu3.model.Count) return convertCount((org.hl7.fhir.dstu3.model.Count) src); if (src instanceof org.hl7.fhir.dstu3.model.Distance) return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); if (src instanceof org.hl7.fhir.dstu3.model.Duration) return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu3.model.Money) - return convertMoney((org.hl7.fhir.dstu3.model.Money) src); + if (src instanceof org.hl7.fhir.dstu3.model.Money) return convertMoney((org.hl7.fhir.dstu3.model.Money) src); if (src instanceof org.hl7.fhir.dstu3.model.SimpleQuantity) return convertSimpleQuantity((org.hl7.fhir.dstu3.model.SimpleQuantity) src); if (src instanceof org.hl7.fhir.dstu3.model.Quantity) return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Range) - return convertRange((org.hl7.fhir.dstu3.model.Range) src); - if (src instanceof org.hl7.fhir.dstu3.model.Ratio) - return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu3.model.Range) return convertRange((org.hl7.fhir.dstu3.model.Range) src); + if (src instanceof org.hl7.fhir.dstu3.model.Ratio) return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); if (src instanceof org.hl7.fhir.dstu3.model.Reference) return convertReference((org.hl7.fhir.dstu3.model.Reference) src); if (src instanceof org.hl7.fhir.dstu3.model.SampledData) @@ -2510,10 +2187,8 @@ public class VersionConvertor_10_30 { return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); if (src instanceof org.hl7.fhir.dstu3.model.HumanName) return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu3.model.Meta) - return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu3.model.Timing) - return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); + if (src instanceof org.hl7.fhir.dstu3.model.Meta) return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu3.model.Timing) return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); throw new FHIRException("Unknown type " + src.fhirType()); } @@ -2544,67 +2219,69 @@ public class VersionConvertor_10_30 { public static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2.model.Resource tgt) throws FHIRException { tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); } static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); tgt.setValue(convertSearchParamType(src.getValue())); @@ -2635,44 +2312,46 @@ public class VersionConvertor_10_30 { } static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + break; + } } return tgt; } static public class SourceElementComponentWrapper { - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { super(); this.source = source; @@ -2681,9 +2360,7 @@ public class VersionConvertor_10_30 { } public String source; - public String target; - public org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent comp; } @@ -2694,214 +2371,209 @@ public class VersionConvertor_10_30 { } static public org.hl7.fhir.dstu3.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertDocumentReferenceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CURRENT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.CURRENT); - break; - case SUPERSEDED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); - break; - case ENTEREDINERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.NULL); + } else { + switch (src.getValue()) { + case CURRENT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.CURRENT); + break; + case SUPERSEDED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); + break; + case ENTEREDINERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.DocumentReferenceStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertDocumentReferenceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CURRENT: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.CURRENT); - break; - case SUPERSEDED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); - break; - case ENTEREDINERROR: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.NULL); + } else { + switch (src.getValue()) { + case CURRENT: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.CURRENT); + break; + case SUPERSEDED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.SUPERSEDED); + break; + case ENTEREDINERROR: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.ENTEREDINERROR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.DocumentReferenceStatus.NULL); + break; + } } return tgt; } static public boolean hasConcept(org.hl7.fhir.dstu3.model.CodeableConcept cc, String system, String code) { for (org.hl7.fhir.dstu3.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; + if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; } return false; } static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; + if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; } return false; } public static org.hl7.fhir.dstu3.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose()) - tgt.setDose(convertType(src.getDose())); - if (src.hasRate()) - tgt.setRate(convertType(src.getRate())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose()) tgt.setDose(convertType(src.getDose())); + if (src.hasRate()) tgt.setRate(convertType(src.getRate())); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); return tgt; } public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertType(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose()) - tgt.setDose(convertType(src.getDose())); - if (src.hasRate()) - tgt.setRate(convertType(src.getRate())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertType(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose()) tgt.setDose(convertType(src.getDose())); + if (src.hasRate()) tgt.setRate(convertType(src.getRate())); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertActionList(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ProcessRequest.ActionListEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CANCEL: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.CANCEL); - break; - case POLL: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.POLL); - break; - case REPROCESS: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.REPROCESS); - break; - case STATUS: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.STATUS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.NULL); + } else { + switch (src.getValue()) { + case CANCEL: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.CANCEL); + break; + case POLL: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.POLL); + break; + case REPROCESS: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.REPROCESS); + break; + case STATUS: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.STATUS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ProcessRequest.ActionList.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertActionList(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ProcessRequest.ActionListEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case CANCEL: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.CANCEL); - break; - case POLL: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.POLL); - break; - case REPROCESS: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.REPROCESS); - break; - case STATUS: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.STATUS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.NULL); + } else { + switch (src.getValue()) { + case CANCEL: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.CANCEL); + break; + case POLL: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.POLL); + break; + case REPROCESS: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.REPROCESS); + break; + case STATUS: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.STATUS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ProcessRequest.ActionList.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent(); copyElement(src, tgt); if (src.hasSequenceLinkIdElement()) @@ -2910,8 +2582,7 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent convertItemsComponent(org.hl7.fhir.dstu3.model.ProcessRequest.ItemsComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent tgt = new org.hl7.fhir.dstu2.model.ProcessRequest.ItemsComponent(); copyElement(src, tgt); if (src.hasSequenceLinkIdElement()) @@ -2920,120 +2591,127 @@ public class VersionConvertor_10_30 { } static public org.hl7.fhir.dstu3.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Slot.SlotStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL); + } else { + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + } else { + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu3.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case REQUESTED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.ACTIVE); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case FAILED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.NULL); + } else { + switch (src.getValue()) { + case REQUESTED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.ACTIVE); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case FAILED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.SupplyRequest.SupplyRequestStatus.NULL); + break; + } } return tgt; } static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); VersionConvertor_10_30.copyElement(src, tgt); - switch (src.getValue()) { - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); - break; + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + } else { + switch (src.getValue()) { + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + break; + } } return tgt; } public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.dstu3.model.CodeSystem src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setSystemElement(convertUri(src.getUrlElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCaseSensitiveElement()) - tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); + if (src.hasUrlElement()) tgt.setSystemElement(convertUri(src.getUrlElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCaseSensitiveElement()) tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); return tgt; } public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent(); copyElement(src, tgt); tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); @@ -3047,8 +2725,7 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); copyElement(src, tgt); tgt.setUse(convertCoding(src.getUse())); @@ -3062,8 +2739,7 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; if (src instanceof org.hl7.fhir.dstu2.model.Parameters) return Parameters10_30.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); if (src instanceof org.hl7.fhir.dstu2.model.Account) @@ -3153,7 +2829,7 @@ public class VersionConvertor_10_30 { if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) return MedicationDispense10_30.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); if (src instanceof org.hl7.fhir.dstu2.model.MedicationOrder) - return MedicationRequest10_30.convertMedicationOrder((org.hl7.fhir.dstu2.model.MedicationOrder)src); + return MedicationRequest10_30.convertMedicationOrder((org.hl7.fhir.dstu2.model.MedicationOrder) src); if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) return MedicationStatement10_30.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) @@ -3214,8 +2890,7 @@ public class VersionConvertor_10_30 { } public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, VersionConvertorAdvisor30 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; + if (src == null || src.isEmpty()) return null; if (src instanceof org.hl7.fhir.dstu3.model.Parameters) return Parameters10_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); if (src instanceof org.hl7.fhir.dstu3.model.Appointment) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index d4628df6e..80516df6c 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -1,67 +1,6 @@ package org.hl7.fhir.convertors; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import org.hl7.fhir.convertors.conv10_40.AllergyIntolerance10_40; -import org.hl7.fhir.convertors.conv10_40.Appointment10_40; -import org.hl7.fhir.convertors.conv10_40.AppointmentResponse10_40; -import org.hl7.fhir.convertors.conv10_40.AuditEvent10_40; -import org.hl7.fhir.convertors.conv10_40.Basic10_40; -import org.hl7.fhir.convertors.conv10_40.Binary10_40; -import org.hl7.fhir.convertors.conv10_40.Bundle10_40; -import org.hl7.fhir.convertors.conv10_40.CarePlan10_40; -import org.hl7.fhir.convertors.conv10_40.Communication10_40; -import org.hl7.fhir.convertors.conv10_40.CommunicationRequest10_40; -import org.hl7.fhir.convertors.conv10_40.Composition10_40; -import org.hl7.fhir.convertors.conv10_40.ConceptMap10_40; -import org.hl7.fhir.convertors.conv10_40.Condition10_40; -import org.hl7.fhir.convertors.conv10_40.Conformance10_40; -import org.hl7.fhir.convertors.conv10_40.DataElement10_40; -import org.hl7.fhir.convertors.conv10_40.DetectedIssue10_40; -import org.hl7.fhir.convertors.conv10_40.DeviceMetric10_40; -import org.hl7.fhir.convertors.conv10_40.DeviceUseStatement10_40; -import org.hl7.fhir.convertors.conv10_40.DiagnosticReport10_40; -import org.hl7.fhir.convertors.conv10_40.DocumentReference10_40; -import org.hl7.fhir.convertors.conv10_40.Encounter10_40; -import org.hl7.fhir.convertors.conv10_40.EnrollmentRequest10_40; -import org.hl7.fhir.convertors.conv10_40.EnrollmentResponse10_40; -import org.hl7.fhir.convertors.conv10_40.EpisodeOfCare10_40; -import org.hl7.fhir.convertors.conv10_40.FamilyMemberHistory10_40; -import org.hl7.fhir.convertors.conv10_40.Flag10_40; -import org.hl7.fhir.convertors.conv10_40.Group10_40; -import org.hl7.fhir.convertors.conv10_40.HealthcareService10_40; -import org.hl7.fhir.convertors.conv10_40.ImplementationGuide10_40; -import org.hl7.fhir.convertors.conv10_40.List10_40; -import org.hl7.fhir.convertors.conv10_40.Location10_40; -import org.hl7.fhir.convertors.conv10_40.MedicationDispense10_40; -import org.hl7.fhir.convertors.conv10_40.MedicationRequest10_40; -import org.hl7.fhir.convertors.conv10_40.MedicationStatement10_40; -import org.hl7.fhir.convertors.conv10_40.MessageHeader10_40; -import org.hl7.fhir.convertors.conv10_40.NamingSystem10_40; -import org.hl7.fhir.convertors.conv10_40.Observation10_40; -import org.hl7.fhir.convertors.conv10_40.OperationDefinition10_40; -import org.hl7.fhir.convertors.conv10_40.OperationOutcome10_40; -import org.hl7.fhir.convertors.conv10_40.Organization10_40; -import org.hl7.fhir.convertors.conv10_40.Parameters10_40; -import org.hl7.fhir.convertors.conv10_40.Patient10_40; -import org.hl7.fhir.convertors.conv10_40.Person10_40; -import org.hl7.fhir.convertors.conv10_40.Practitioner10_40; -import org.hl7.fhir.convertors.conv10_40.Questionnaire10_40; -import org.hl7.fhir.convertors.conv10_40.QuestionnaireResponse10_40; -import org.hl7.fhir.convertors.conv10_40.RiskAssessment10_40; -import org.hl7.fhir.convertors.conv10_40.Schedule10_40; -import org.hl7.fhir.convertors.conv10_40.SearchParameter10_40; -import org.hl7.fhir.convertors.conv10_40.Slot10_40; -import org.hl7.fhir.convertors.conv10_40.StructureDefinition10_40; -import org.hl7.fhir.convertors.conv10_40.Subscription10_40; -import org.hl7.fhir.convertors.conv10_40.Substance10_40; -import org.hl7.fhir.convertors.conv10_40.SupplyDelivery10_40; -import org.hl7.fhir.convertors.conv10_40.SupplyRequest10_40; -import org.hl7.fhir.convertors.conv10_40.TestScript10_40; -import org.hl7.fhir.convertors.conv10_40.ValueSet10_40; +import org.hl7.fhir.convertors.conv10_40.*; import org.hl7.fhir.dstu2.model.CodeableConcept; import org.hl7.fhir.dstu2.model.Parameters; import org.hl7.fhir.dstu2.model.Parameters.ParametersParameterComponent; @@ -70,17 +9,24 @@ import org.hl7.fhir.dstu2.model.Reference; import org.hl7.fhir.dstu2.utils.ToolingExtensions; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.conformance.ProfileUtilities; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.CanonicalType; +import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent; import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent; import org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent; import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; import org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent; -import org.hl7.fhir.r4.model.Timing.EventTiming; +import org.hl7.fhir.r4.model.TerminologyCapabilities; +import org.hl7.fhir.r4.model.UnsignedIntType; import org.hl7.fhir.r4.terminologies.CodeSystemUtilities; import org.hl7.fhir.utilities.Utilities; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + /* Copyright (c) 2011+, HL7, Inc. All rights reserved. @@ -107,3333 +53,3017 @@ import org.hl7.fhir.utilities.Utilities; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ + public class VersionConvertor_10_40 { + static public List CANONICAL_URLS = new ArrayList(); - static public List CANONICAL_URLS = new ArrayList(); + static { + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + } - static { - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.r4.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); } + } - public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.r4.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); + public static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public static void copyElement(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDateTimeToDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { + org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { + org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValue()) : new org.hl7.fhir.r4.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { + org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { + org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { + org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { + org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2.model.Reference) + tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) + tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); + else if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + tgt.setUrl(src.getUrl()); + if (src.hasSizeElement()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHashElement()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + tgt.setUrl(src.getUrl()); + if (src.hasSizeElement()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHashElement()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); + copyElement(src, tgt); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); + copyElement(src, tgt); + if (src.hasStartElement()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); + copyElement(src, tgt); + if (src.hasStartElement()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); + copyElement(src, tgt); + tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); + copyElement(src, tgt); + tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); + else tgt.setWho(convertReference(src.getWhoReference())); + if (src.hasContentTypeElement()) tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); + if (src.hasBlobElement()) tgt.setDataElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasSigFormatElement()) tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); + if (src.hasDataElement()) tgt.setBlobElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCityElement()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCityElement()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRankElement()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_10_40::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasName()) { + if (slicePaths.contains(src.getPath())) tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasNameElement()) tgt.setIdElement(convertString(src.getNameElement())); + } + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasNameReference()) tgt.setContentReference("#" + src.getNameReference()); + for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertElementDefinitionTypeComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (tgt.getIsModifier()) { + String reason = org.hl7.fhir.dstu2.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); + if (Utilities.noString(reason)) reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; + tgt.setIsModifierReason(reason); + } + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + if (!tgt.hasId()) tgt.setId(tgt.getPath()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_10_40::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setNameElement(convertString(src.getSliceNameElement())); + else tgt.setNameElement(convertString(src.getIdElement())); + if (src.hasLabelElement()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShortElement()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinitionElement()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasCommentElement()) tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setNameReference(src.getContentReference().substring(1)); + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertElementDefinitionTypeComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissingElement()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.setExample(convertType(src.getExampleFirstRep().getValue())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLengthElement()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupportElement()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifierElement()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) + org.hl7.fhir.dstu2.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); + if (src.hasIsSummaryElement()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + org.hl7.fhir.dstu2.model.ElementDefinition slicingElement = context.get(pos); + for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) { + boolean isExists = false; + if (!t.asStringValue().contains("@")) { + int slices = 0; + boolean existsSlicePresent = false; + boolean notExistsSlicePresent = false; + String existsPath = slicingElement.getPath() + "." + t.asStringValue(); + for (int i = pos + 1; i < context.size(); i++) { + org.hl7.fhir.dstu2.model.ElementDefinition e = context.get(i); + if (e.getPath().equals(slicingElement.getPath())) slices++; + else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) break; + else if (e.getPath().equals(existsPath)) { + if (e.hasMin() && e.getMin() > 0) existsSlicePresent = true; + else if (e.hasMax() && e.getMax().equals("0")) notExistsSlicePresent = true; + } } - } - - public static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public static void copyElement(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.Element tgt) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDateTimeToDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValue()) : new org.hl7.fhir.r4.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2.model.Reference) - tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) - tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); - else if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - tgt.setUrl(src.getUrl()); - if (src.hasSizeElement()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - tgt.setUrl(src.getUrl()); - if (src.hasSizeElement()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); - copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); - copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); - copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); - copyElement(src, tgt); - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); - copyElement(src, tgt); - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWhoUriType()) - tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); - else - tgt.setWho(convertReference(src.getWhoReference())); - if (src.hasContentTypeElement()) - tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); - if (src.hasBlobElement()) - tgt.setDataElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasSigFormatElement()) - tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); - if (src.hasDataElement()) - tgt.setBlobElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRankElement()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_40::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasName()) { - if (slicePaths.contains(src.getPath())) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasNameElement()) - tgt.setIdElement(convertString(src.getNameElement())); - } - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasNameReference()) - tgt.setContentReference("#" + src.getNameReference()); - for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) convertElementDefinitionTypeComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (tgt.getIsModifier()) { - String reason = org.hl7.fhir.dstu2.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); - if (Utilities.noString(reason)) - reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; - tgt.setIsModifierReason(reason); - } - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - if (!tgt.hasId()) - tgt.setId(tgt.getPath()); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_40::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - else - tgt.setNameElement(convertString(src.getIdElement())); - if (src.hasLabelElement()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShortElement()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinitionElement()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasCommentElement()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setNameReference(src.getContentReference().substring(1)); - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) convertElementDefinitionTypeComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissingElement()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExampleFirstRep().getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLengthElement()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupportElement()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifierElement()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) - org.hl7.fhir.dstu2.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); - if (src.hasIsSummaryElement()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - org.hl7.fhir.dstu2.model.ElementDefinition slicingElement = context.get(pos); - for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) { - boolean isExists = false; - if (!t.asStringValue().contains("@")) { - int slices = 0; - boolean existsSlicePresent = false; - boolean notExistsSlicePresent = false; - String existsPath = slicingElement.getPath() + "." + t.asStringValue(); - for (int i = pos + 1; i < context.size(); i++) { - org.hl7.fhir.dstu2.model.ElementDefinition e = context.get(i); - if (e.getPath().equals(slicingElement.getPath())) - slices++; - else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) - break; - else if (e.getPath().equals(existsPath)) { - if (e.hasMin() && e.getMin() > 0) - existsSlicePresent = true; - else if (e.hasMax() && e.getMax().equals("0")) - notExistsSlicePresent = true; - } - } - isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); - } - tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); - } - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static void convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = null; - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : list) if (t.getCode().equals(src.getCode())) - tgt = t; - if (tgt == null) { - tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - } - if (tgt.hasTarget()) { - for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addTargetProfile(u.getValue()); - } else { - for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.r4.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregationElement().setValue(a.getValue())); - } - } - - public static void convertElementDefinitionTypeComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - list.add(tgt); - if (src.hasTarget()) { - for (org.hl7.fhir.r4.model.UriType u : src.getTargetProfile()) { - tgt.addProfile(u.getValue()); - } - } else { - for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { - tgt.addProfile(u.getValue()); - } - } - } - - static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - org.hl7.fhir.r4.model.Type vs = convertType(src.getValueSet()); - if (vs != null) { - tgt.setValueSet(vs instanceof org.hl7.fhir.r4.model.Reference ? ((org.hl7.fhir.r4.model.Reference) vs).getReference() : vs.primitiveValue()); - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu2.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu2.model.Reference(src.getValueSet())); - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnits()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnits()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); - if (src.hasWhen()) { - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - } - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCodeElement()) - tgt.setCurrencyElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrencyElement()) - tgt.setCodeElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu2.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu2.model.CodeType) - return convertCode((org.hl7.fhir.dstu2.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DateType) - return convertDate((org.hl7.fhir.dstu2.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IdType) - return convertId((org.hl7.fhir.dstu2.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu2.model.InstantType) - return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2.model.OidType) - return convertOid((org.hl7.fhir.dstu2.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu2.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu2.model.StringType) - return convertString((org.hl7.fhir.dstu2.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu2.model.TimeType) - return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu2.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UriType) - return convertUri((org.hl7.fhir.dstu2.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UuidType) - return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.Extension) - return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu2.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu2.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu2.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu2.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu2.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2.model.Coding) - return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu2.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2.model.Period) - return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2.model.Range) - return convertRange((org.hl7.fhir.dstu2.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu2.model.Reference) - return convertReference((org.hl7.fhir.dstu2.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu2.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu2.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu2.model.Signature) - return convertSignature((org.hl7.fhir.dstu2.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu2.model.Address) - return convertAddress((org.hl7.fhir.dstu2.model.Address) src); - if (src instanceof org.hl7.fhir.dstu2.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu2.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu2.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2.model.Meta) - return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2.model.Timing) - return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); - if (src instanceof org.hl7.fhir.dstu2.model.Age) - return convertAge((org.hl7.fhir.dstu2.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2.model.Count) - return convertCount((org.hl7.fhir.dstu2.model.Count) src); - if (src instanceof org.hl7.fhir.dstu2.model.Distance) - return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu2.model.Duration) - return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2.model.Money) - return convertMoney((org.hl7.fhir.dstu2.model.Money) src); - if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r4.model.BooleanType) - return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r4.model.CodeType) - return convertCode((org.hl7.fhir.r4.model.CodeType) src); - if (src instanceof org.hl7.fhir.r4.model.DateType) - return convertDate((org.hl7.fhir.r4.model.DateType) src); - if (src instanceof org.hl7.fhir.r4.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r4.model.DecimalType) - return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r4.model.IdType) - return convertId((org.hl7.fhir.r4.model.IdType) src); - if (src instanceof org.hl7.fhir.r4.model.InstantType) - return convertInstant((org.hl7.fhir.r4.model.InstantType) src); - if (src instanceof org.hl7.fhir.r4.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r4.model.OidType) - return convertOid((org.hl7.fhir.r4.model.OidType) src); - if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r4.model.StringType) - return convertString((org.hl7.fhir.r4.model.StringType) src); - if (src instanceof org.hl7.fhir.r4.model.TimeType) - return convertTime((org.hl7.fhir.r4.model.TimeType) src); - if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r4.model.IntegerType) - return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r4.model.UriType) - return convertUri((org.hl7.fhir.r4.model.UriType) src); - if (src instanceof org.hl7.fhir.r4.model.UuidType) - return convertUuid((org.hl7.fhir.r4.model.UuidType) src); - if (src instanceof org.hl7.fhir.r4.model.Extension) - return convertExtension((org.hl7.fhir.r4.model.Extension) src); - if (src instanceof org.hl7.fhir.r4.model.Narrative) - return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); - if (src instanceof org.hl7.fhir.r4.model.Annotation) - return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); - if (src instanceof org.hl7.fhir.r4.model.Attachment) - return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); - if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r4.model.Coding) - return convertCoding((org.hl7.fhir.r4.model.Coding) src); - if (src instanceof org.hl7.fhir.r4.model.Identifier) - return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); - if (src instanceof org.hl7.fhir.r4.model.Period) - return convertPeriod((org.hl7.fhir.r4.model.Period) src); - if (src instanceof org.hl7.fhir.r4.model.Quantity) - return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); - if (src instanceof org.hl7.fhir.r4.model.Range) - return convertRange((org.hl7.fhir.r4.model.Range) src); - if (src instanceof org.hl7.fhir.r4.model.Ratio) - return convertRatio((org.hl7.fhir.r4.model.Ratio) src); - if (src instanceof org.hl7.fhir.r4.model.Reference) - return convertReference((org.hl7.fhir.r4.model.Reference) src); - if (src instanceof org.hl7.fhir.r4.model.SampledData) - return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); - if (src instanceof org.hl7.fhir.r4.model.Signature) - return convertSignature((org.hl7.fhir.r4.model.Signature) src); - if (src instanceof org.hl7.fhir.r4.model.Address) - return convertAddress((org.hl7.fhir.r4.model.Address) src); - if (src instanceof org.hl7.fhir.r4.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r4.model.HumanName) - return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); - if (src instanceof org.hl7.fhir.r4.model.Meta) - return convertMeta((org.hl7.fhir.r4.model.Meta) src); - if (src instanceof org.hl7.fhir.r4.model.Timing) - return convertTiming((org.hl7.fhir.r4.model.Timing) src); - if (src instanceof org.hl7.fhir.r4.model.Age) - return convertAge((org.hl7.fhir.r4.model.Age) src); - if (src instanceof org.hl7.fhir.r4.model.Count) - return convertCount((org.hl7.fhir.r4.model.Count) src); - if (src instanceof org.hl7.fhir.r4.model.Distance) - return convertDistance((org.hl7.fhir.r4.model.Distance) src); - if (src instanceof org.hl7.fhir.r4.model.Duration) - return convertDuration((org.hl7.fhir.r4.model.Duration) src); - if (src instanceof org.hl7.fhir.r4.model.Money) - return convertMoney((org.hl7.fhir.r4.model.Money) src); - if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) if (s.equals(url)) - ok = true; - return ok; - } - - public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - public static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { - tgt.setId(src.getId()); - tgt.setMeta(convertMeta(src.getMeta())); - tgt.setImplicitRules(src.getImplicitRules()); - tgt.setLanguage(src.getLanguage()); - } - - public static void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu2.model.Resource tgt) throws FHIRException { - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public org.hl7.fhir.r4.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public class SourceElementComponentWrapper { - - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - public String source; - - public String target; - - public org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent comp; - } - - public static org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext(); - result.setValue(convertCodeableConcept(t)); - return result; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); - break; - } - return tgt; - } - - static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { - CanonicalType dst = new CanonicalType(src.getReference()); - copyElement(src, dst); - return dst; - } - - static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { - Reference dst = new Reference(src.getValue()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityModeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConformanceEventModeEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Reference getPerformer(List practitioner) { - for (ImmunizationPerformerComponent p : practitioner) { - if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "AP")) - return p.getActor(); - } - return null; - } - - static public org.hl7.fhir.r4.model.Reference getRequester(List practitioner) { - for (ImmunizationPerformerComponent p : practitioner) { - if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "OP")) - return p.getActor(); - } - return null; - } - - static public boolean hasConcept(org.hl7.fhir.r4.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.r4.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } - - static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } - - public static org.hl7.fhir.r4.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); - copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose() || src.hasRate()) { - DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); - if (src.hasDose()) - dr.setDose(convertType(src.getDose())); - if (src.hasRate()) - dr.setRate(convertType(src.getRate())); - } - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); - copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertType(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) - tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) - tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Slot.SlotStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case REQUESTED: - tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ACTIVE); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case FAILED: - tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); - VersionConvertor_10_40.copyElement(src, tgt); - switch(src.getValue()) { - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setSystemElement(convertUri(src.getUrlElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCaseSensitiveElement()) - tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); - for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent(); - copyElement(src, tgt); - tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); - tgt.setCode(src.getCode()); - tgt.setDefinition(src.getDefinition()); - tgt.setDisplay(src.getDisplay()); - for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc)); - for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) tgt.addDesignation(convertCodeSystemDesignation(cc)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); - copyElement(src, tgt); - tgt.setUse(convertCoding(src.getUse())); - tgt.setLanguage(src.getLanguage()); - tgt.setValue(src.getValue()); - return tgt; - } - - static public boolean isJurisdiction(CodeableConcept t) { - return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); - } - - public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor40 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2.model.Parameters) - return Parameters10_40.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu2.model.Appointment) - return Appointment10_40.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); - if (src instanceof org.hl7.fhir.dstu2.model.AllergyIntolerance) - return AllergyIntolerance10_40.convertAllergyIntolerance((org.hl7.fhir.dstu2.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) - return AppointmentResponse10_40.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) - return AuditEvent10_40.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.dstu2.model.Basic) - return Basic10_40.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); - if (src instanceof org.hl7.fhir.dstu2.model.Binary) - return Binary10_40.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); - if (src instanceof org.hl7.fhir.dstu2.model.Bundle) - return Bundle10_40.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) - return CarePlan10_40.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); - if (src instanceof org.hl7.fhir.dstu2.model.Communication) - return Communication10_40.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); - if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) - return CommunicationRequest10_40.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.Composition) - return Composition10_40.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); - if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) - return ConceptMap10_40.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu2.model.Condition) - return Condition10_40.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); - if (src instanceof org.hl7.fhir.dstu2.model.Conformance) - return Conformance10_40.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); - if (src instanceof org.hl7.fhir.dstu2.model.DataElement) - return DataElement10_40.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) - return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) - return DeviceMetric10_40.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) - return DeviceUseStatement10_40.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) - return DiagnosticReport10_40.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) - return DocumentReference10_40.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.dstu2.model.Encounter) - return Encounter10_40.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); - if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) - return EnrollmentRequest10_40.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) - return EnrollmentResponse10_40.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) - return EpisodeOfCare10_40.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) - return FamilyMemberHistory10_40.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.dstu2.model.Flag) - return Flag10_40.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); - if (src instanceof org.hl7.fhir.dstu2.model.Group) - return Group10_40.convertGroup((org.hl7.fhir.dstu2.model.Group) src); - if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) - return HealthcareService10_40.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) - return ImplementationGuide10_40.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu2.model.List_) - return List10_40.convertList((org.hl7.fhir.dstu2.model.List_) src); - if (src instanceof org.hl7.fhir.dstu2.model.Location) - return Location10_40.convertLocation((org.hl7.fhir.dstu2.model.Location) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) - return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) - return MedicationStatement10_40.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationOrder) - return MedicationRequest10_40.convertMedicationRequest((org.hl7.fhir.dstu2.model.MedicationOrder) src); - if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) - return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) - return NamingSystem10_40.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu2.model.Observation) - return Observation10_40.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); - if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) - return OperationDefinition10_40.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) - return OperationOutcome10_40.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu2.model.Organization) - return Organization10_40.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); - if (src instanceof org.hl7.fhir.dstu2.model.Patient) - return Patient10_40.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); - if (src instanceof org.hl7.fhir.dstu2.model.Person) - return Person10_40.convertPerson((org.hl7.fhir.dstu2.model.Person) src); - if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) - return Practitioner10_40.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); - if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) - return Questionnaire10_40.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) - return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) - return RiskAssessment10_40.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.dstu2.model.Schedule) - return Schedule10_40.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); - if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) - return SearchParameter10_40.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu2.model.Slot) - return Slot10_40.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); - if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) - return StructureDefinition10_40.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu2.model.Subscription) - return Subscription10_40.convertSubscription((org.hl7.fhir.dstu2.model.Subscription) src); - if (src instanceof org.hl7.fhir.dstu2.model.Substance) - return Substance10_40.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); - if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) - return SupplyDelivery10_40.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) - return SupplyRequest10_40.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.TestScript) - return TestScript10_40.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) - return ValueSet10_40.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, VersionConvertorAdvisor40 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r4.model.Parameters) - return Parameters10_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); - if (src instanceof org.hl7.fhir.r4.model.Appointment) - return Appointment10_40.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); - if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) - return AppointmentResponse10_40.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.r4.model.AuditEvent) - return AuditEvent10_40.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.r4.model.Basic) - return Basic10_40.convertBasic((org.hl7.fhir.r4.model.Basic) src); - if (src instanceof org.hl7.fhir.r4.model.Binary) - return Binary10_40.convertBinary((org.hl7.fhir.r4.model.Binary) src); - if (src instanceof org.hl7.fhir.r4.model.Bundle) - return Bundle10_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src, advisor); - if (src instanceof org.hl7.fhir.r4.model.CarePlan) - return CarePlan10_40.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); - if (src instanceof org.hl7.fhir.r4.model.Communication) - return Communication10_40.convertCommunication((org.hl7.fhir.r4.model.Communication) src); - if (src instanceof org.hl7.fhir.r4.model.CommunicationRequest) - return CommunicationRequest10_40.convertCommunicationRequest((org.hl7.fhir.r4.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.r4.model.Composition) - return Composition10_40.convertComposition((org.hl7.fhir.r4.model.Composition) src); - if (src instanceof org.hl7.fhir.r4.model.ConceptMap) - return ConceptMap10_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r4.model.Condition) - return Condition10_40.convertCondition((org.hl7.fhir.r4.model.Condition) src); - if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) - return Conformance10_40.convertConformance((org.hl7.fhir.r4.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) - return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceMetric) - return DeviceMetric10_40.convertDeviceMetric((org.hl7.fhir.r4.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) - return DeviceUseStatement10_40.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) - return DiagnosticReport10_40.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.r4.model.DocumentReference) - return DocumentReference10_40.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r4.model.Encounter) - return Encounter10_40.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); - if (src instanceof org.hl7.fhir.r4.model.EnrollmentRequest) - return EnrollmentRequest10_40.convertEnrollmentRequest((org.hl7.fhir.r4.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.r4.model.EnrollmentResponse) - return EnrollmentResponse10_40.convertEnrollmentResponse((org.hl7.fhir.r4.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) - return EpisodeOfCare10_40.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) - return FamilyMemberHistory10_40.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.r4.model.Flag) - return Flag10_40.convertFlag((org.hl7.fhir.r4.model.Flag) src); - if (src instanceof org.hl7.fhir.r4.model.Group) - return Group10_40.convertGroup((org.hl7.fhir.r4.model.Group) src); - if (src instanceof org.hl7.fhir.r4.model.HealthcareService) - return HealthcareService10_40.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) - return ImplementationGuide10_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r4.model.ListResource) - return List10_40.convertList((org.hl7.fhir.r4.model.ListResource) src); - if (src instanceof org.hl7.fhir.r4.model.Location) - return Location10_40.convertLocation((org.hl7.fhir.r4.model.Location) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) - return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) - return MedicationStatement10_40.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.r4.model.MessageHeader) - return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.r4.model.NamingSystem) - return NamingSystem10_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r4.model.Observation) - return Observation10_40.convertObservation((org.hl7.fhir.r4.model.Observation) src); - if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) - return OperationDefinition10_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) - return OperationOutcome10_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r4.model.Organization) - return Organization10_40.convertOrganization((org.hl7.fhir.r4.model.Organization) src); - if (src instanceof org.hl7.fhir.r4.model.Patient) - return Patient10_40.convertPatient((org.hl7.fhir.r4.model.Patient) src); - if (src instanceof org.hl7.fhir.r4.model.Person) - return Person10_40.convertPerson((org.hl7.fhir.r4.model.Person) src); - if (src instanceof org.hl7.fhir.r4.model.Practitioner) - return Practitioner10_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); - if (src instanceof org.hl7.fhir.r4.model.Questionnaire) - return Questionnaire10_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) - return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) - return RiskAssessment10_40.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.r4.model.Schedule) - return Schedule10_40.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); - if (src instanceof org.hl7.fhir.r4.model.SearchParameter) - return SearchParameter10_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r4.model.Slot) - return Slot10_40.convertSlot((org.hl7.fhir.r4.model.Slot) src); - if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) - return StructureDefinition10_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Subscription) - return Subscription10_40.convertSubscription((org.hl7.fhir.r4.model.Subscription) src); - if (src instanceof org.hl7.fhir.r4.model.Substance) - return Substance10_40.convertSubstance((org.hl7.fhir.r4.model.Substance) src); - if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) - return SupplyDelivery10_40.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.r4.model.SupplyRequest) - return SupplyRequest10_40.convertSupplyRequest((org.hl7.fhir.r4.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.r4.model.TestScript) - return TestScript10_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); - if (src instanceof org.hl7.fhir.r4.model.ValueSet) - return ValueSet10_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src, advisor); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src) { - TerminologyCapabilities res = new TerminologyCapabilities(); - for (ParametersParameterComponent p : src.getParameter()) { - if (p.getName().equals("system")) - res.addCodeSystem().setUri(p.getValue().primitiveValue()); - } - return res; - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "DetectedIssue", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImplementationGuide", "ListResource", "Location", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Questionnaire", "QuestionnaireResponse", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet"); - } - - public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { - return convertResource(src, null); - } - - public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { - return convertResource(src, null); - } - - public static UnsignedIntType convertUnsignedIntToPositive(PositiveIntType src) { - org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); + isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); + } + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); + } + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static void convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = null; + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : list) + if (t.getCode().equals(src.getCode())) tgt = t; + if (tgt == null) { + tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); copyElement(src, tgt); - return tgt; + tgt.setCode(src.getCode()); } -} + if (tgt.hasTarget()) { + for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addTargetProfile(u.getValue()); + } else { + for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.r4.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregationElement().setValue(a.getValue())); + } + } + + public static void convertElementDefinitionTypeComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + list.add(tgt); + if (src.hasTarget()) { + for (org.hl7.fhir.r4.model.UriType u : src.getTargetProfile()) { + tgt.addProfile(u.getValue()); + } + } else { + for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { + tgt.addProfile(u.getValue()); + } + } + } + + static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) + ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + org.hl7.fhir.r4.model.Type vs = convertType(src.getValueSet()); + if (vs != null) { + tgt.setValueSet(vs instanceof org.hl7.fhir.r4.model.Reference ? ((org.hl7.fhir.r4.model.Reference) vs).getReference() : vs.primitiveValue()); + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu2.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu2.model.Reference(src.getValueSet())); + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionIdElement()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionIdElement()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasDurationElement()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnits()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); + if (src.hasWhen()) { + tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + } + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasDurationElement()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) { + tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCodeElement()) tgt.setCurrencyElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrencyElement()) tgt.setCodeElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu2.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu2.model.CodeType) + return convertCode((org.hl7.fhir.dstu2.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DateType) + return convertDate((org.hl7.fhir.dstu2.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IdType) return convertId((org.hl7.fhir.dstu2.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2.model.InstantType) + return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu2.model.OidType) return convertOid((org.hl7.fhir.dstu2.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu2.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu2.model.StringType) + return convertString((org.hl7.fhir.dstu2.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu2.model.TimeType) + return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu2.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UriType) return convertUri((org.hl7.fhir.dstu2.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UuidType) + return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.Extension) + return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu2.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu2.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu2.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu2.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu2.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu2.model.Coding) return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu2.model.Period) return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu2.model.Range) return convertRange((org.hl7.fhir.dstu2.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2.model.Ratio) return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2.model.Reference) + return convertReference((org.hl7.fhir.dstu2.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu2.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu2.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu2.model.Signature) + return convertSignature((org.hl7.fhir.dstu2.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu2.model.Address) + return convertAddress((org.hl7.fhir.dstu2.model.Address) src); + if (src instanceof org.hl7.fhir.dstu2.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu2.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu2.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu2.model.Meta) return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2.model.Timing) return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); + if (src instanceof org.hl7.fhir.dstu2.model.Age) return convertAge((org.hl7.fhir.dstu2.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2.model.Count) return convertCount((org.hl7.fhir.dstu2.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2.model.Distance) + return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu2.model.Duration) + return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu2.model.Money) return convertMoney((org.hl7.fhir.dstu2.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r4.model.BooleanType) + return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r4.model.CodeType) return convertCode((org.hl7.fhir.r4.model.CodeType) src); + if (src instanceof org.hl7.fhir.r4.model.DateType) return convertDate((org.hl7.fhir.r4.model.DateType) src); + if (src instanceof org.hl7.fhir.r4.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r4.model.DecimalType) + return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r4.model.IdType) return convertId((org.hl7.fhir.r4.model.IdType) src); + if (src instanceof org.hl7.fhir.r4.model.InstantType) + return convertInstant((org.hl7.fhir.r4.model.InstantType) src); + if (src instanceof org.hl7.fhir.r4.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r4.model.OidType) return convertOid((org.hl7.fhir.r4.model.OidType) src); + if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r4.model.StringType) + return convertString((org.hl7.fhir.r4.model.StringType) src); + if (src instanceof org.hl7.fhir.r4.model.TimeType) return convertTime((org.hl7.fhir.r4.model.TimeType) src); + if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r4.model.IntegerType) + return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r4.model.UriType) return convertUri((org.hl7.fhir.r4.model.UriType) src); + if (src instanceof org.hl7.fhir.r4.model.UuidType) return convertUuid((org.hl7.fhir.r4.model.UuidType) src); + if (src instanceof org.hl7.fhir.r4.model.Extension) + return convertExtension((org.hl7.fhir.r4.model.Extension) src); + if (src instanceof org.hl7.fhir.r4.model.Narrative) + return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); + if (src instanceof org.hl7.fhir.r4.model.Annotation) + return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); + if (src instanceof org.hl7.fhir.r4.model.Attachment) + return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); + if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r4.model.Coding) return convertCoding((org.hl7.fhir.r4.model.Coding) src); + if (src instanceof org.hl7.fhir.r4.model.Identifier) + return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); + if (src instanceof org.hl7.fhir.r4.model.Period) return convertPeriod((org.hl7.fhir.r4.model.Period) src); + if (src instanceof org.hl7.fhir.r4.model.Quantity) return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); + if (src instanceof org.hl7.fhir.r4.model.Range) return convertRange((org.hl7.fhir.r4.model.Range) src); + if (src instanceof org.hl7.fhir.r4.model.Ratio) return convertRatio((org.hl7.fhir.r4.model.Ratio) src); + if (src instanceof org.hl7.fhir.r4.model.Reference) + return convertReference((org.hl7.fhir.r4.model.Reference) src); + if (src instanceof org.hl7.fhir.r4.model.SampledData) + return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); + if (src instanceof org.hl7.fhir.r4.model.Signature) + return convertSignature((org.hl7.fhir.r4.model.Signature) src); + if (src instanceof org.hl7.fhir.r4.model.Address) return convertAddress((org.hl7.fhir.r4.model.Address) src); + if (src instanceof org.hl7.fhir.r4.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r4.model.HumanName) + return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); + if (src instanceof org.hl7.fhir.r4.model.Meta) return convertMeta((org.hl7.fhir.r4.model.Meta) src); + if (src instanceof org.hl7.fhir.r4.model.Timing) return convertTiming((org.hl7.fhir.r4.model.Timing) src); + if (src instanceof org.hl7.fhir.r4.model.Age) return convertAge((org.hl7.fhir.r4.model.Age) src); + if (src instanceof org.hl7.fhir.r4.model.Count) return convertCount((org.hl7.fhir.r4.model.Count) src); + if (src instanceof org.hl7.fhir.r4.model.Distance) return convertDistance((org.hl7.fhir.r4.model.Distance) src); + if (src instanceof org.hl7.fhir.r4.model.Duration) return convertDuration((org.hl7.fhir.r4.model.Duration) src); + if (src instanceof org.hl7.fhir.r4.model.Money) return convertMoney((org.hl7.fhir.r4.model.Money) src); + if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; + } + + public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + public static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { + tgt.setId(src.getId()); + tgt.setMeta(convertMeta(src.getMeta())); + tgt.setImplicitRules(src.getImplicitRules()); + tgt.setLanguage(src.getLanguage()); + } + + public static void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu2.model.Resource tgt) throws FHIRException { + tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public org.hl7.fhir.r4.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public class SourceElementComponentWrapper { + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; + } + + public String source; + public String target; + public org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent comp; + } + + public static org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext(); + result.setValue(convertCodeableConcept(t)); + return result; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + break; + } + } + return tgt; + } + + static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { + CanonicalType dst = new CanonicalType(src.getReference()); + copyElement(src, dst); + return dst; + } + + static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { + Reference dst = new Reference(src.getValue()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityModeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConformanceEventModeEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Reference getPerformer(List practitioner) { + for (ImmunizationPerformerComponent p : practitioner) { + if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "AP")) return p.getActor(); + } + return null; + } + + static public org.hl7.fhir.r4.model.Reference getRequester(List practitioner) { + for (ImmunizationPerformerComponent p : practitioner) { + if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "OP")) return p.getActor(); + } + return null; + } + + static public boolean hasConcept(org.hl7.fhir.r4.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.r4.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; + } + return false; + } + + static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; + } + return false; + } + + public static org.hl7.fhir.r4.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); + copyElement(src, tgt); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose() || src.hasRate()) { + DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); + if (src.hasDose()) dr.setDose(convertType(src.getDose())); + if (src.hasRate()) dr.setRate(convertType(src.getRate())); + } + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); + copyElement(src, tgt); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertType(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) + tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) + tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Slot.SlotStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.NULL); + } else { + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Slot.SlotStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + } else { + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL); + } else { + switch (src.getValue()) { + case REQUESTED: + tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ACTIVE); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case FAILED: + tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); + VersionConvertor_10_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + } else { + switch (src.getValue()) { + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r4.model.CodeSystem src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setSystemElement(convertUri(src.getUrlElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCaseSensitiveElement()) tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); + for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent(); + copyElement(src, tgt); + tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); + tgt.setCode(src.getCode()); + tgt.setDefinition(src.getDefinition()); + tgt.setDisplay(src.getDisplay()); + for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc)); + for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) + tgt.addDesignation(convertCodeSystemDesignation(cc)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); + copyElement(src, tgt); + tgt.setUse(convertCoding(src.getUse())); + tgt.setLanguage(src.getLanguage()); + tgt.setValue(src.getValue()); + return tgt; + } + + static public boolean isJurisdiction(CodeableConcept t) { + return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); + } + + public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor40 advisor) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2.model.Parameters) + return Parameters10_40.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu2.model.Appointment) + return Appointment10_40.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); + if (src instanceof org.hl7.fhir.dstu2.model.AllergyIntolerance) + return AllergyIntolerance10_40.convertAllergyIntolerance((org.hl7.fhir.dstu2.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) + return AppointmentResponse10_40.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) + return AuditEvent10_40.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.dstu2.model.Basic) + return Basic10_40.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); + if (src instanceof org.hl7.fhir.dstu2.model.Binary) + return Binary10_40.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); + if (src instanceof org.hl7.fhir.dstu2.model.Bundle) + return Bundle10_40.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) + return CarePlan10_40.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); + if (src instanceof org.hl7.fhir.dstu2.model.Communication) + return Communication10_40.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); + if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) + return CommunicationRequest10_40.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.Composition) + return Composition10_40.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); + if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) + return ConceptMap10_40.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu2.model.Condition) + return Condition10_40.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); + if (src instanceof org.hl7.fhir.dstu2.model.Conformance) + return Conformance10_40.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); + if (src instanceof org.hl7.fhir.dstu2.model.DataElement) + return DataElement10_40.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) + return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) + return DeviceMetric10_40.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) + return DeviceUseStatement10_40.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) + return DiagnosticReport10_40.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) + return DocumentReference10_40.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.dstu2.model.Encounter) + return Encounter10_40.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); + if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) + return EnrollmentRequest10_40.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) + return EnrollmentResponse10_40.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) + return EpisodeOfCare10_40.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) + return FamilyMemberHistory10_40.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.dstu2.model.Flag) + return Flag10_40.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); + if (src instanceof org.hl7.fhir.dstu2.model.Group) + return Group10_40.convertGroup((org.hl7.fhir.dstu2.model.Group) src); + if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) + return HealthcareService10_40.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) + return ImplementationGuide10_40.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu2.model.List_) + return List10_40.convertList((org.hl7.fhir.dstu2.model.List_) src); + if (src instanceof org.hl7.fhir.dstu2.model.Location) + return Location10_40.convertLocation((org.hl7.fhir.dstu2.model.Location) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) + return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) + return MedicationStatement10_40.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationOrder) + return MedicationRequest10_40.convertMedicationRequest((org.hl7.fhir.dstu2.model.MedicationOrder) src); + if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) + return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) + return NamingSystem10_40.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu2.model.Observation) + return Observation10_40.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); + if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) + return OperationDefinition10_40.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) + return OperationOutcome10_40.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu2.model.Organization) + return Organization10_40.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); + if (src instanceof org.hl7.fhir.dstu2.model.Patient) + return Patient10_40.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); + if (src instanceof org.hl7.fhir.dstu2.model.Person) + return Person10_40.convertPerson((org.hl7.fhir.dstu2.model.Person) src); + if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) + return Practitioner10_40.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); + if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) + return Questionnaire10_40.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) + return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) + return RiskAssessment10_40.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.dstu2.model.Schedule) + return Schedule10_40.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); + if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) + return SearchParameter10_40.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu2.model.Slot) + return Slot10_40.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); + if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) + return StructureDefinition10_40.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu2.model.Subscription) + return Subscription10_40.convertSubscription((org.hl7.fhir.dstu2.model.Subscription) src); + if (src instanceof org.hl7.fhir.dstu2.model.Substance) + return Substance10_40.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); + if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) + return SupplyDelivery10_40.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) + return SupplyRequest10_40.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.TestScript) + return TestScript10_40.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) + return ValueSet10_40.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, VersionConvertorAdvisor40 advisor) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r4.model.Parameters) + return Parameters10_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); + if (src instanceof org.hl7.fhir.r4.model.Appointment) + return Appointment10_40.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); + if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) + return AppointmentResponse10_40.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.r4.model.AuditEvent) + return AuditEvent10_40.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.r4.model.Basic) + return Basic10_40.convertBasic((org.hl7.fhir.r4.model.Basic) src); + if (src instanceof org.hl7.fhir.r4.model.Binary) + return Binary10_40.convertBinary((org.hl7.fhir.r4.model.Binary) src); + if (src instanceof org.hl7.fhir.r4.model.Bundle) + return Bundle10_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src, advisor); + if (src instanceof org.hl7.fhir.r4.model.CarePlan) + return CarePlan10_40.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); + if (src instanceof org.hl7.fhir.r4.model.Communication) + return Communication10_40.convertCommunication((org.hl7.fhir.r4.model.Communication) src); + if (src instanceof org.hl7.fhir.r4.model.CommunicationRequest) + return CommunicationRequest10_40.convertCommunicationRequest((org.hl7.fhir.r4.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.r4.model.Composition) + return Composition10_40.convertComposition((org.hl7.fhir.r4.model.Composition) src); + if (src instanceof org.hl7.fhir.r4.model.ConceptMap) + return ConceptMap10_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r4.model.Condition) + return Condition10_40.convertCondition((org.hl7.fhir.r4.model.Condition) src); + if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) + return Conformance10_40.convertConformance((org.hl7.fhir.r4.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) + return DetectedIssue10_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceMetric) + return DeviceMetric10_40.convertDeviceMetric((org.hl7.fhir.r4.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) + return DeviceUseStatement10_40.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) + return DiagnosticReport10_40.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.r4.model.DocumentReference) + return DocumentReference10_40.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r4.model.Encounter) + return Encounter10_40.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); + if (src instanceof org.hl7.fhir.r4.model.EnrollmentRequest) + return EnrollmentRequest10_40.convertEnrollmentRequest((org.hl7.fhir.r4.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.r4.model.EnrollmentResponse) + return EnrollmentResponse10_40.convertEnrollmentResponse((org.hl7.fhir.r4.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) + return EpisodeOfCare10_40.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) + return FamilyMemberHistory10_40.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.r4.model.Flag) return Flag10_40.convertFlag((org.hl7.fhir.r4.model.Flag) src); + if (src instanceof org.hl7.fhir.r4.model.Group) + return Group10_40.convertGroup((org.hl7.fhir.r4.model.Group) src); + if (src instanceof org.hl7.fhir.r4.model.HealthcareService) + return HealthcareService10_40.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) + return ImplementationGuide10_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r4.model.ListResource) + return List10_40.convertList((org.hl7.fhir.r4.model.ListResource) src); + if (src instanceof org.hl7.fhir.r4.model.Location) + return Location10_40.convertLocation((org.hl7.fhir.r4.model.Location) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) + return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) + return MedicationStatement10_40.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.r4.model.MessageHeader) + return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.r4.model.NamingSystem) + return NamingSystem10_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r4.model.Observation) + return Observation10_40.convertObservation((org.hl7.fhir.r4.model.Observation) src); + if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) + return OperationDefinition10_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) + return OperationOutcome10_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r4.model.Organization) + return Organization10_40.convertOrganization((org.hl7.fhir.r4.model.Organization) src); + if (src instanceof org.hl7.fhir.r4.model.Patient) + return Patient10_40.convertPatient((org.hl7.fhir.r4.model.Patient) src); + if (src instanceof org.hl7.fhir.r4.model.Person) + return Person10_40.convertPerson((org.hl7.fhir.r4.model.Person) src); + if (src instanceof org.hl7.fhir.r4.model.Practitioner) + return Practitioner10_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); + if (src instanceof org.hl7.fhir.r4.model.Questionnaire) + return Questionnaire10_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) + return QuestionnaireResponse10_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) + return RiskAssessment10_40.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.r4.model.Schedule) + return Schedule10_40.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); + if (src instanceof org.hl7.fhir.r4.model.SearchParameter) + return SearchParameter10_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r4.model.Slot) return Slot10_40.convertSlot((org.hl7.fhir.r4.model.Slot) src); + if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) + return StructureDefinition10_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Subscription) + return Subscription10_40.convertSubscription((org.hl7.fhir.r4.model.Subscription) src); + if (src instanceof org.hl7.fhir.r4.model.Substance) + return Substance10_40.convertSubstance((org.hl7.fhir.r4.model.Substance) src); + if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) + return SupplyDelivery10_40.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r4.model.SupplyRequest) + return SupplyRequest10_40.convertSupplyRequest((org.hl7.fhir.r4.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.r4.model.TestScript) + return TestScript10_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); + if (src instanceof org.hl7.fhir.r4.model.ValueSet) + return ValueSet10_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src, advisor); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src) { + TerminologyCapabilities res = new TerminologyCapabilities(); + for (ParametersParameterComponent p : src.getParameter()) { + if (p.getName().equals("system")) res.addCodeSystem().setUri(p.getValue().primitiveValue()); + } + return res; + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "DetectedIssue", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImplementationGuide", "ListResource", "Location", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Questionnaire", "QuestionnaireResponse", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet"); + } + + public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { + return convertResource(src, null); + } + + public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { + return convertResource(src, null); + } + + public static UnsignedIntType convertUnsignedIntToPositive(PositiveIntType src) { + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } +} \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java index 16f419902..42bfbbdde 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java @@ -1,65 +1,6 @@ package org.hl7.fhir.convertors; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import org.hl7.fhir.convertors.conv10_50.Appointment10_50; -import org.hl7.fhir.convertors.conv10_50.AppointmentResponse10_50; -import org.hl7.fhir.convertors.conv10_50.AuditEvent10_50; -import org.hl7.fhir.convertors.conv10_50.Basic10_50; -import org.hl7.fhir.convertors.conv10_50.Binary10_50; -import org.hl7.fhir.convertors.conv10_50.Bundle10_50; -import org.hl7.fhir.convertors.conv10_50.CarePlan10_50; -import org.hl7.fhir.convertors.conv10_50.Communication10_50; -import org.hl7.fhir.convertors.conv10_50.CommunicationRequest10_50; -import org.hl7.fhir.convertors.conv10_50.Composition10_50; -import org.hl7.fhir.convertors.conv10_50.ConceptMap10_50; -import org.hl7.fhir.convertors.conv10_50.Condition10_50; -import org.hl7.fhir.convertors.conv10_50.Conformance10_50; -import org.hl7.fhir.convertors.conv10_50.DataElement10_50; -import org.hl7.fhir.convertors.conv10_50.DetectedIssue10_50; -import org.hl7.fhir.convertors.conv10_50.DeviceMetric10_50; -import org.hl7.fhir.convertors.conv10_50.DeviceUseStatement10_50; -import org.hl7.fhir.convertors.conv10_50.DiagnosticReport10_50; -import org.hl7.fhir.convertors.conv10_50.DocumentReference10_50; -import org.hl7.fhir.convertors.conv10_50.Encounter10_50; -import org.hl7.fhir.convertors.conv10_50.EnrollmentRequest10_50; -import org.hl7.fhir.convertors.conv10_50.EnrollmentResponse10_50; -import org.hl7.fhir.convertors.conv10_50.EpisodeOfCare10_50; -import org.hl7.fhir.convertors.conv10_50.FamilyMemberHistory10_50; -import org.hl7.fhir.convertors.conv10_50.Flag10_50; -import org.hl7.fhir.convertors.conv10_50.Group10_50; -import org.hl7.fhir.convertors.conv10_50.HealthcareService10_50; -import org.hl7.fhir.convertors.conv10_50.ImplementationGuide10_50; -import org.hl7.fhir.convertors.conv10_50.List10_50; -import org.hl7.fhir.convertors.conv10_50.Location10_50; -import org.hl7.fhir.convertors.conv10_50.MedicationDispense10_50; -import org.hl7.fhir.convertors.conv10_50.MedicationStatement10_50; -import org.hl7.fhir.convertors.conv10_50.MessageHeader10_50; -import org.hl7.fhir.convertors.conv10_50.NamingSystem10_50; -import org.hl7.fhir.convertors.conv10_50.Observation10_50; -import org.hl7.fhir.convertors.conv10_50.OperationDefinition10_50; -import org.hl7.fhir.convertors.conv10_50.OperationOutcome10_50; -import org.hl7.fhir.convertors.conv10_50.Organization10_50; -import org.hl7.fhir.convertors.conv10_50.Parameters10_50; -import org.hl7.fhir.convertors.conv10_50.Patient10_50; -import org.hl7.fhir.convertors.conv10_50.Person10_50; -import org.hl7.fhir.convertors.conv10_50.Practitioner10_50; -import org.hl7.fhir.convertors.conv10_50.Provenance10_50; -import org.hl7.fhir.convertors.conv10_50.Questionnaire10_50; -import org.hl7.fhir.convertors.conv10_50.QuestionnaireResponse10_50; -import org.hl7.fhir.convertors.conv10_50.RiskAssessment10_50; -import org.hl7.fhir.convertors.conv10_50.Schedule10_50; -import org.hl7.fhir.convertors.conv10_50.SearchParameter10_50; -import org.hl7.fhir.convertors.conv10_50.Slot10_50; -import org.hl7.fhir.convertors.conv10_50.StructureDefinition10_50; -import org.hl7.fhir.convertors.conv10_50.Substance10_50; -import org.hl7.fhir.convertors.conv10_50.SupplyDelivery10_50; -import org.hl7.fhir.convertors.conv10_50.SupplyRequest10_50; -import org.hl7.fhir.convertors.conv10_50.TestScript10_50; -import org.hl7.fhir.convertors.conv10_50.ValueSet10_50; +import org.hl7.fhir.convertors.conv10_50.*; import org.hl7.fhir.dstu2.model.CodeableConcept; import org.hl7.fhir.dstu2.model.Parameters; import org.hl7.fhir.dstu2.model.Parameters.ParametersParameterComponent; @@ -75,13 +16,16 @@ import org.hl7.fhir.r5.model.CodeableReference; import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; import org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent; import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; -import org.hl7.fhir.r5.model.Enumeration; import org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent; import org.hl7.fhir.r5.model.TerminologyCapabilities; -import org.hl7.fhir.r5.model.Timing.EventTiming; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.utilities.Utilities; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + /* Copyright (c) 2011+, HL7, Inc. All rights reserved. @@ -108,3364 +52,3031 @@ import org.hl7.fhir.utilities.Utilities; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ + public class VersionConvertor_10_50 { + static public List CANONICAL_URLS = new ArrayList(); - static public List CANONICAL_URLS = new ArrayList(); - - static { - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); - } - - public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - public static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu2.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - public static void copyElement(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - tgt.setId(src.getId()); - for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDateTimeToDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); - copyElement(src, tgt); - return tgt; + static { + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); } - public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); - copyElement(src, tgt); - return tgt; + public static void copyElement(org.hl7.fhir.dstu2.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.dstu2.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } } + } - public static org.hl7.fhir.dstu2.model.StringType convertMarkdownToString(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); - copyElement(src, tgt); - return tgt; + public static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu2.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } } + } - public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); - copyElement(src, tgt); - return tgt; + public static void copyElement(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + tgt.setId(src.getId()); + for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } } + } - public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; + public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu2.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu2.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu2.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UriType convertCodeToUri(org.hl7.fhir.dstu2.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeType convertUriToCode(org.hl7.fhir.r5.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu2.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu2.model.DateType src) throws FHIRException { + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDateTimeToDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateType convertDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu2.model.IdType src) throws FHIRException { + org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu2.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IdType(src.getValue()) : new org.hl7.fhir.dstu2.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2.model.InstantType src) throws FHIRException { + org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu2.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.InstantType(src.getValue()) : new org.hl7.fhir.dstu2.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu2.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu2.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu2.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu2.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu2.model.OidType src) throws FHIRException { + org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu2.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.OidType(src.getValue()) : new org.hl7.fhir.dstu2.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu2.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.dstu2.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.StringType convertMarkdownToString(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.StringType(src.getValue()) : new org.hl7.fhir.dstu2.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu2.model.TimeType src) throws FHIRException { + org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu2.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu2.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { + org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2.model.Reference) + tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) + tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); + else if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.dstu2.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu2.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu2.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); - copyElement(src, tgt); - return tgt; + public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTimeElement()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSize(Long.valueOf(src.getSize())); + if (src.hasHashElement()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasDataElement()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSize(Math.toIntExact(src.getSize())); + if (src.hasHashElement()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitleElement()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreationElement()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); + copyElement(src, tgt); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); + copyElement(src, tgt); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelectedElement()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.dstu2.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UriType(src.getValue()) : new org.hl7.fhir.dstu2.model.UriType(); - copyElement(src, tgt); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu2.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); - copyElement(src, tgt); - return tgt; + public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); + copyElement(src, tgt); + if (src.hasStartElement()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); + copyElement(src, tgt); + if (src.hasStartElement()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEndElement()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.dstu2.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu2.model.UuidType(); - copyElement(src, tgt); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu2.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2.model.Reference) - tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; + public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); + copyElement(src, tgt); + tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); + copyElement(src, tgt); + tgt.setReference(src.getReference()); + if (src.hasDisplayElement()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactorElement()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimitElement()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimitElement()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r5.model.Reference(src.getWhoUriType().getValue())); + else tgt.setWho(convertReference(src.getWhoReference())); + if (src.hasContentTypeElement()) tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); + if (src.hasBlobElement()) tgt.setDataElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasSigFormatElement()) tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); + if (src.hasDataElement()) tgt.setBlobElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCityElement()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCityElement()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrictElement()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasStateElement()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCodeElement()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountryElement()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.dstu2.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Extension tgt = new org.hl7.fhir.dstu2.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) - tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); - else if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.dstu2.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; + static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + break; + } } + return tgt; + } - public static org.hl7.fhir.dstu2.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Narrative tgt = new org.hl7.fhir.dstu2.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; + static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); + break; + } } + return tgt; + } - static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); - break; + public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRankElement()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValueElement()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRankElement()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_10_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasName()) { + if (slicePaths.contains(src.getPath())) tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasNameElement()) tgt.setIdElement(convertString(src.getNameElement())); + } + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasNameReference()) tgt.setContentReference("#" + src.getNameReference()); + for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertElementDefinitionTypeComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (tgt.getIsModifier()) { + String reason = org.hl7.fhir.dstu2.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); + if (Utilities.noString(reason)) reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; + tgt.setIsModifierReason(reason); + } + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + if (!tgt.hasId()) tgt.setId(tgt.getPath()); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_10_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setNameElement(convertString(src.getSliceNameElement())); + else tgt.setNameElement(convertString(src.getIdElement())); + if (src.hasLabelElement()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShortElement()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinitionElement()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasCommentElement()) tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setNameReference(src.getContentReference().substring(1)); + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertElementDefinitionTypeComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissingElement()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.setExample(convertType(src.getExampleFirstRep().getValue())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLengthElement()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupportElement()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifierElement()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) + org.hl7.fhir.dstu2.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); + if (src.hasIsSummaryElement()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + org.hl7.fhir.dstu2.model.ElementDefinition slicingElement = context.get(pos); + for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) { + boolean isExists = false; + if (!t.asStringValue().contains("@")) { + int slices = 0; + boolean existsSlicePresent = false; + boolean notExistsSlicePresent = false; + String existsPath = slicingElement.getPath() + "." + t.asStringValue(); + for (int i = pos + 1; i < context.size(); i++) { + org.hl7.fhir.dstu2.model.ElementDefinition e = context.get(i); + if (e.getPath().equals(slicingElement.getPath())) slices++; + else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) break; + else if (e.getPath().equals(existsPath)) { + if (e.hasMin() && e.getMin() > 0) existsSlicePresent = true; + else if (e.hasMax() && e.getMax().equals("0")) notExistsSlicePresent = true; + } } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.dstu2.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Annotation tgt = new org.hl7.fhir.dstu2.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTimeElement()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu2.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSize(Long.valueOf(src.getSize())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Attachment tgt = new org.hl7.fhir.dstu2.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSize(Math.toIntExact(src.getSize())); - if (src.hasHashElement()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitleElement()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreationElement()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu2.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); - copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Coding tgt = new org.hl7.fhir.dstu2.model.Coding(); - copyElement(src, tgt); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelectedElement()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu2.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Identifier tgt = new org.hl7.fhir.dstu2.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.dstu2.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); - copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Period tgt = new org.hl7.fhir.dstu2.model.Period(); - copyElement(src, tgt); - if (src.hasStartElement()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEndElement()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu2.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Quantity tgt = new org.hl7.fhir.dstu2.model.Quantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.dstu2.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Range tgt = new org.hl7.fhir.dstu2.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.dstu2.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Ratio tgt = new org.hl7.fhir.dstu2.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.dstu2.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); - copyElement(src, tgt); - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Reference tgt = new org.hl7.fhir.dstu2.model.Reference(); - copyElement(src, tgt); - tgt.setReference(src.getReference()); - if (src.hasDisplayElement()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.dstu2.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.SampledData tgt = new org.hl7.fhir.dstu2.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactorElement()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimitElement()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimitElement()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.dstu2.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWhoUriType()) - tgt.setWho(new org.hl7.fhir.r5.model.Reference(src.getWhoUriType().getValue())); - else - tgt.setWho(convertReference(src.getWhoReference())); - if (src.hasContentTypeElement()) - tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); - if (src.hasBlobElement()) - tgt.setDataElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Signature tgt = new org.hl7.fhir.dstu2.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasSigFormatElement()) - tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); - if (src.hasDataElement()) - tgt.setBlobElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.dstu2.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Address tgt = new org.hl7.fhir.dstu2.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCityElement()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrictElement()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasStateElement()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCodeElement()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountryElement()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Address.AddressTypeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRankElement()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ContactPoint tgt = new org.hl7.fhir.dstu2.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValueElement()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRankElement()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition src, List slicePaths, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasName()) { - if (slicePaths.contains(src.getPath())) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasNameElement()) - tgt.setIdElement(convertString(src.getNameElement())); - } - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasNameReference()) - tgt.setContentReference("#" + src.getNameReference()); - for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : src.getType()) convertElementDefinitionTypeComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu2.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (tgt.getIsModifier()) { - String reason = org.hl7.fhir.dstu2.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); - if (Utilities.noString(reason)) - reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; - tgt.setIsModifierReason(reason); - } - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - if (!tgt.hasId()) - tgt.setId(tgt.getPath()); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition tgt = new org.hl7.fhir.dstu2.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_10_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - else - tgt.setNameElement(convertString(src.getIdElement())); - if (src.hasLabelElement()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShortElement()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinitionElement()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasCommentElement()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setNameReference(src.getContentReference().substring(1)); - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) convertElementDefinitionTypeComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissingElement()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExampleFirstRep().getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLengthElement()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupportElement()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifierElement()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) - org.hl7.fhir.dstu2.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); - if (src.hasIsSummaryElement()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - org.hl7.fhir.dstu2.model.ElementDefinition slicingElement = context.get(pos); - for (org.hl7.fhir.dstu2.model.StringType t : src.getDiscriminator()) { - boolean isExists = false; - if (!t.asStringValue().contains("@")) { - int slices = 0; - boolean existsSlicePresent = false; - boolean notExistsSlicePresent = false; - String existsPath = slicingElement.getPath() + "." + t.asStringValue(); - for (int i = pos + 1; i < context.size(); i++) { - org.hl7.fhir.dstu2.model.ElementDefinition e = context.get(i); - if (e.getPath().equals(slicingElement.getPath())) - slices++; - else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) - break; - else if (e.getPath().equals(existsPath)) { - if (e.hasMin() && e.getMin() > 0) - existsSlicePresent = true; - else if (e.hasMax() && e.getMax().equals("0")) - notExistsSlicePresent = true; - } - } - isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); - } - tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); - } - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrderedElement()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static void convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = null; - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : list) if (t.getCode().equals(src.getCode())) - tgt = t; - if (tgt == null) { - tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - } - if (tgt.hasTarget()) { - for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addTargetProfile(u.getValue()); - } else { - for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.r5.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregation(a.getValue())); - } - } - - public static void convertElementDefinitionTypeComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(src.getCode()); - list.add(tgt); - if (src.hasTarget()) { - for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) { - tgt.addProfile(u.getValue()); - } - } else { - for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { - tgt.addProfile(u.getValue()); - } - } - } - - static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirementsElement()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - org.hl7.fhir.r5.model.DataType vs = convertType(src.getValueSet()); - if (vs != null) { - tgt.setValueSet(vs instanceof org.hl7.fhir.r5.model.Reference ? ((org.hl7.fhir.r5.model.Reference) vs).getReference() : vs.primitiveValue()); - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescriptionElement()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu2.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu2.model.Reference(src.getValueSet())); - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguageElement()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionIdElement()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdatedElement()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnits()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnits()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasDurationElement()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMaxElement()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMaxElement()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCodeElement()) - tgt.setCurrencyElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrencyElement()) - tgt.setCodeElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.SimpleQuantity tgt = new org.hl7.fhir.r5.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValueElement()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnitElement()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystemElement()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCodeElement()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu2.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu2.model.CodeType) - return convertCode((org.hl7.fhir.dstu2.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DateType) - return convertDate((org.hl7.fhir.dstu2.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IdType) - return convertId((org.hl7.fhir.dstu2.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu2.model.InstantType) - return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2.model.OidType) - return convertOid((org.hl7.fhir.dstu2.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu2.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu2.model.StringType) - return convertString((org.hl7.fhir.dstu2.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu2.model.TimeType) - return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu2.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu2.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UriType) - return convertUri((org.hl7.fhir.dstu2.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu2.model.UuidType) - return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2.model.Extension) - return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu2.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu2.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu2.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu2.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu2.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2.model.Coding) - return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu2.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2.model.Period) - return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2.model.Range) - return convertRange((org.hl7.fhir.dstu2.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu2.model.Reference) - return convertReference((org.hl7.fhir.dstu2.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu2.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu2.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu2.model.Signature) - return convertSignature((org.hl7.fhir.dstu2.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu2.model.Address) - return convertAddress((org.hl7.fhir.dstu2.model.Address) src); - if (src instanceof org.hl7.fhir.dstu2.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu2.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu2.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2.model.Meta) - return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2.model.Timing) - return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); - if (src instanceof org.hl7.fhir.dstu2.model.Age) - return convertAge((org.hl7.fhir.dstu2.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2.model.Count) - return convertCount((org.hl7.fhir.dstu2.model.Count) src); - if (src instanceof org.hl7.fhir.dstu2.model.Distance) - return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu2.model.Duration) - return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2.model.Money) - return convertMoney((org.hl7.fhir.dstu2.model.Money) src); - if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r5.model.BooleanType) - return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r5.model.CodeType) - return convertCode((org.hl7.fhir.r5.model.CodeType) src); - if (src instanceof org.hl7.fhir.r5.model.DateType) - return convertDate((org.hl7.fhir.r5.model.DateType) src); - if (src instanceof org.hl7.fhir.r5.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r5.model.DecimalType) - return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r5.model.IdType) - return convertId((org.hl7.fhir.r5.model.IdType) src); - if (src instanceof org.hl7.fhir.r5.model.InstantType) - return convertInstant((org.hl7.fhir.r5.model.InstantType) src); - if (src instanceof org.hl7.fhir.r5.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r5.model.OidType) - return convertOid((org.hl7.fhir.r5.model.OidType) src); - if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r5.model.StringType) - return convertString((org.hl7.fhir.r5.model.StringType) src); - if (src instanceof org.hl7.fhir.r5.model.TimeType) - return convertTime((org.hl7.fhir.r5.model.TimeType) src); - if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r5.model.IntegerType) - return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r5.model.UriType) - return convertUri((org.hl7.fhir.r5.model.UriType) src); - if (src instanceof org.hl7.fhir.r5.model.UuidType) - return convertUuid((org.hl7.fhir.r5.model.UuidType) src); - if (src instanceof org.hl7.fhir.r5.model.Extension) - return convertExtension((org.hl7.fhir.r5.model.Extension) src); - if (src instanceof org.hl7.fhir.r5.model.Narrative) - return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); - if (src instanceof org.hl7.fhir.r5.model.Annotation) - return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); - if (src instanceof org.hl7.fhir.r5.model.Attachment) - return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); - if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r5.model.Coding) - return convertCoding((org.hl7.fhir.r5.model.Coding) src); - if (src instanceof org.hl7.fhir.r5.model.Identifier) - return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); - if (src instanceof org.hl7.fhir.r5.model.Period) - return convertPeriod((org.hl7.fhir.r5.model.Period) src); - if (src instanceof org.hl7.fhir.r5.model.Quantity) - return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); - if (src instanceof org.hl7.fhir.r5.model.Range) - return convertRange((org.hl7.fhir.r5.model.Range) src); - if (src instanceof org.hl7.fhir.r5.model.Ratio) - return convertRatio((org.hl7.fhir.r5.model.Ratio) src); - if (src instanceof org.hl7.fhir.r5.model.Reference) - return convertReference((org.hl7.fhir.r5.model.Reference) src); - if (src instanceof org.hl7.fhir.r5.model.SampledData) - return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); - if (src instanceof org.hl7.fhir.r5.model.Signature) - return convertSignature((org.hl7.fhir.r5.model.Signature) src); - if (src instanceof org.hl7.fhir.r5.model.Address) - return convertAddress((org.hl7.fhir.r5.model.Address) src); - if (src instanceof org.hl7.fhir.r5.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r5.model.HumanName) - return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); - if (src instanceof org.hl7.fhir.r5.model.Meta) - return convertMeta((org.hl7.fhir.r5.model.Meta) src); - if (src instanceof org.hl7.fhir.r5.model.Timing) - return convertTiming((org.hl7.fhir.r5.model.Timing) src); - if (src instanceof org.hl7.fhir.r5.model.Age) - return convertAge((org.hl7.fhir.r5.model.Age) src); - if (src instanceof org.hl7.fhir.r5.model.Count) - return convertCount((org.hl7.fhir.r5.model.Count) src); - if (src instanceof org.hl7.fhir.r5.model.Distance) - return convertDistance((org.hl7.fhir.r5.model.Distance) src); - if (src instanceof org.hl7.fhir.r5.model.Duration) - return convertDuration((org.hl7.fhir.r5.model.Duration) src); - if (src instanceof org.hl7.fhir.r5.model.Money) - return convertMoney((org.hl7.fhir.r5.model.Money) src); - if (src instanceof org.hl7.fhir.r5.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.r5.model.SimpleQuantity) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) if (s.equals(url)) - ok = true; - return ok; - } - - public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - public static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - public static void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu2.model.Resource tgt) throws FHIRException { - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public org.hl7.fhir.r5.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public CodeableReference convertCodeableConceptToCodableReference(CodeableConcept src) { - CodeableReference tgt = new CodeableReference(); - tgt.setConcept(convertCodeableConcept(src)); - return tgt; - } - - static public class SourceElementComponentWrapper { - - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - public String source; - - public String target; - - public org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent comp; - } - - public static org.hl7.fhir.r5.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.r5.model.UsageContext result = new org.hl7.fhir.r5.model.UsageContext(); - result.setValue(convertCodeableConcept(t)); - return result; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); - break; - } - return tgt; - } - - static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { - CanonicalType dst = new CanonicalType(src.getReference()); - copyElement(src, dst); - return dst; - } - - static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { - Reference dst = new Reference(src.getValue()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityModeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConformanceEventModeEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Reference getPerformer(List practitioner) { - for (ImmunizationPerformerComponent p : practitioner) { - if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "AP")) - return p.getActor(); - } - return null; - } - - static public org.hl7.fhir.r5.model.Reference getRequester(List practitioner) { - for (ImmunizationPerformerComponent p : practitioner) { - if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "OP")) - return p.getActor(); - } - return null; - } - - static public boolean hasConcept(org.hl7.fhir.r5.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.r5.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } - - static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { - for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { - if (system.equals(c.getSystem()) && code.equals(c.getCode())) - return true; - } - return false; - } - - public static org.hl7.fhir.r5.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Dosage tgt = new org.hl7.fhir.r5.model.Dosage(); - copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSiteCodeableConcept()) - tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose() || src.hasRate()) { - DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); - if (src.hasDose()) - dr.setDose(convertType(src.getDose())); - if (src.hasRate()) - dr.setRate(convertType(src.getRate())); - } - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.r5.model.Dosage src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); - copyElement(src, tgt); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertType(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) - tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) - tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Slot.SlotStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case BUSY: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); - break; - case FREE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); - break; - case BUSYUNAVAILABLE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); - break; - case BUSYTENTATIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUESTED: - tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.ACTIVE); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case FAILED: - tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); - VersionConvertor_10_50.copyElement(src, tgt); - switch(src.getValue()) { - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); - break; - case COMPLETED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); - break; - case CANCELLED: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r5.model.CodeSystem src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setSystemElement(convertUri(src.getUrlElement())); - if (src.hasVersionElement()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCaseSensitiveElement()) - tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); - for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent(); - copyElement(src, tgt); - tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); - if (src.hasCode()) - tgt.setCode(src.getCode()); - if (src.hasDefinition()) - tgt.setDefinition(src.getDefinition()); - if (src.hasDisplay()) - tgt.setDisplay(src.getDisplay()); - for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc)); - for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) tgt.addDesignation(convertCodeSystemDesignation(cc)); - return tgt; - } - - public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUse(convertCoding(src.getUse())); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - if (src.hasValue()) - tgt.setValue(src.getValue()); - return tgt; - } - - static public boolean isJurisdiction(CodeableConcept t) { - return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); - } - - public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor50 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2.model.Parameters) - return Parameters10_50.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu2.model.Appointment) - return Appointment10_50.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); - if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) - return AppointmentResponse10_50.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) - return AuditEvent10_50.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.dstu2.model.Basic) - return Basic10_50.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); - if (src instanceof org.hl7.fhir.dstu2.model.Binary) - return Binary10_50.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); - if (src instanceof org.hl7.fhir.dstu2.model.Bundle) - return Bundle10_50.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) - return CarePlan10_50.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); - if (src instanceof org.hl7.fhir.dstu2.model.Communication) - return Communication10_50.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); - if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) - return CommunicationRequest10_50.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.Composition) - return Composition10_50.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); - if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) - return ConceptMap10_50.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu2.model.Condition) - return Condition10_50.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); - if (src instanceof org.hl7.fhir.dstu2.model.Conformance) - return Conformance10_50.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); - if (src instanceof org.hl7.fhir.dstu2.model.DataElement) - return DataElement10_50.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) - return DetectedIssue10_50.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) - return DeviceMetric10_50.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) - return DeviceUseStatement10_50.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) - return DiagnosticReport10_50.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) - return DocumentReference10_50.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.dstu2.model.Encounter) - return Encounter10_50.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); - if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) - return EnrollmentRequest10_50.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) - return EnrollmentResponse10_50.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) - return EpisodeOfCare10_50.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) - return FamilyMemberHistory10_50.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.dstu2.model.Flag) - return Flag10_50.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); - if (src instanceof org.hl7.fhir.dstu2.model.Group) - return Group10_50.convertGroup((org.hl7.fhir.dstu2.model.Group) src); - if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) - return HealthcareService10_50.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) - return ImplementationGuide10_50.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu2.model.List_) - return List10_50.convertList((org.hl7.fhir.dstu2.model.List_) src); - if (src instanceof org.hl7.fhir.dstu2.model.Location) - return Location10_50.convertLocation((org.hl7.fhir.dstu2.model.Location) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) - return MedicationDispense10_50.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) - return MedicationStatement10_50.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) - return MessageHeader10_50.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) - return NamingSystem10_50.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu2.model.Observation) - return Observation10_50.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); - if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) - return OperationDefinition10_50.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) - return OperationOutcome10_50.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu2.model.Organization) - return Organization10_50.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); - if (src instanceof org.hl7.fhir.dstu2.model.Patient) - return Patient10_50.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); - if (src instanceof org.hl7.fhir.dstu2.model.Person) - return Person10_50.convertPerson((org.hl7.fhir.dstu2.model.Person) src); - if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) - return Practitioner10_50.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); - if (src instanceof org.hl7.fhir.dstu2.model.Provenance) - return Provenance10_50.convertProvenance((org.hl7.fhir.dstu2.model.Provenance) src); - if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) - return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) - return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) - return RiskAssessment10_50.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.dstu2.model.Schedule) - return Schedule10_50.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); - if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) - return SearchParameter10_50.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu2.model.Slot) - return Slot10_50.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); - if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) - return StructureDefinition10_50.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu2.model.Substance) - return Substance10_50.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); - if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) - return SupplyDelivery10_50.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) - return SupplyRequest10_50.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.dstu2.model.TestScript) - return TestScript10_50.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) - return ValueSet10_50.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, VersionConvertorAdvisor50 advisor) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r5.model.Parameters) - return Parameters10_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); - if (src instanceof org.hl7.fhir.r5.model.Appointment) - return Appointment10_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); - if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) - return AppointmentResponse10_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.r5.model.AuditEvent) - return AuditEvent10_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.r5.model.Basic) - return Basic10_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); - if (src instanceof org.hl7.fhir.r5.model.Binary) - return Binary10_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); - if (src instanceof org.hl7.fhir.r5.model.Bundle) - return Bundle10_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src, advisor); - if (src instanceof org.hl7.fhir.r5.model.CarePlan) - return CarePlan10_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); - if (src instanceof org.hl7.fhir.r5.model.Communication) - return Communication10_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); - if (src instanceof org.hl7.fhir.r5.model.CommunicationRequest) - return CommunicationRequest10_50.convertCommunicationRequest((org.hl7.fhir.r5.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.r5.model.Composition) - return Composition10_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); - if (src instanceof org.hl7.fhir.r5.model.ConceptMap) - return ConceptMap10_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r5.model.Condition) - return Condition10_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); - if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) - return Conformance10_50.convertConformance((org.hl7.fhir.r5.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) - return DetectedIssue10_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceMetric) - return DeviceMetric10_50.convertDeviceMetric((org.hl7.fhir.r5.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceUseStatement) - return DeviceUseStatement10_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) - return DiagnosticReport10_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.r5.model.DocumentReference) - return DocumentReference10_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r5.model.Encounter) - return Encounter10_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); - if (src instanceof org.hl7.fhir.r5.model.EnrollmentRequest) - return EnrollmentRequest10_50.convertEnrollmentRequest((org.hl7.fhir.r5.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.r5.model.EnrollmentResponse) - return EnrollmentResponse10_50.convertEnrollmentResponse((org.hl7.fhir.r5.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) - return EpisodeOfCare10_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) - return FamilyMemberHistory10_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.r5.model.Flag) - return Flag10_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); - if (src instanceof org.hl7.fhir.r5.model.Group) - return Group10_50.convertGroup((org.hl7.fhir.r5.model.Group) src); - if (src instanceof org.hl7.fhir.r5.model.HealthcareService) - return HealthcareService10_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) - return ImplementationGuide10_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r5.model.ListResource) - return List10_50.convertList((org.hl7.fhir.r5.model.ListResource) src); - if (src instanceof org.hl7.fhir.r5.model.Location) - return Location10_50.convertLocation((org.hl7.fhir.r5.model.Location) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) - return MedicationDispense10_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationUsage) - return MedicationStatement10_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationUsage) src); - if (src instanceof org.hl7.fhir.r5.model.MessageHeader) - return MessageHeader10_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.r5.model.NamingSystem) - return NamingSystem10_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r5.model.Observation) - return Observation10_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); - if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) - return OperationDefinition10_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) - return OperationOutcome10_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r5.model.Organization) - return Organization10_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); - if (src instanceof org.hl7.fhir.r5.model.Patient) - return Patient10_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); - if (src instanceof org.hl7.fhir.r5.model.Person) - return Person10_50.convertPerson((org.hl7.fhir.r5.model.Person) src); - if (src instanceof org.hl7.fhir.r5.model.Practitioner) - return Practitioner10_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); - if (src instanceof org.hl7.fhir.r5.model.Provenance) - return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); - if (src instanceof org.hl7.fhir.r5.model.Questionnaire) - return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) - return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) - return RiskAssessment10_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.r5.model.Schedule) - return Schedule10_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); - if (src instanceof org.hl7.fhir.r5.model.SearchParameter) - return SearchParameter10_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r5.model.Slot) - return Slot10_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); - if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) - return StructureDefinition10_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Substance) - return Substance10_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); - if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) - return SupplyDelivery10_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.r5.model.SupplyRequest) - return SupplyRequest10_50.convertSupplyRequest((org.hl7.fhir.r5.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.r5.model.TestScript) - return TestScript10_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); - if (src instanceof org.hl7.fhir.r5.model.ValueSet) - return ValueSet10_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src, advisor); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src) { - TerminologyCapabilities res = new TerminologyCapabilities(); - for (ParametersParameterComponent p : src.getParameter()) { - if (p.getName().equals("system")) - res.addCodeSystem().setUri(p.getValue().primitiveValue()); - if (p.getName().equals("expansion.parameter")) - res.getExpansion().addParameter().setName(p.getValue().primitiveValue()); - } - return res; - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "DetectedIssue", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImplementationGuide", "ListResource", "Location", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Questionnaire", "QuestionnaireResponse", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet"); - } - - public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { - return convertResource(src, null); - } - - public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { - return convertResource(src, null); - } + isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); + } + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); + } + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrderedElement()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static void convertElementDefinitionTypeComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = null; + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : list) + if (t.getCode().equals(src.getCode())) tgt = t; + if (tgt == null) { + tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + } + if (tgt.hasTarget()) { + for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addTargetProfile(u.getValue()); + } else { + for (org.hl7.fhir.dstu2.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.r5.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue())); + } + } + + public static void convertElementDefinitionTypeComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(src.getCode()); + list.add(tgt); + if (src.hasTarget()) { + for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) { + tgt.addProfile(u.getValue()); + } + } else { + for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { + tgt.addProfile(u.getValue()); + } + } + } + + static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirementsElement()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) + ToolingExtensions.addStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + org.hl7.fhir.r5.model.DataType vs = convertType(src.getValueSet()); + if (vs != null) { + tgt.setValueSet(vs instanceof org.hl7.fhir.r5.model.Reference ? ((org.hl7.fhir.r5.model.Reference) vs).getReference() : vs.primitiveValue()); + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescriptionElement()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu2.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu2.model.Reference(src.getValueSet())); + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertBindingStrength(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguageElement()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.dstu2.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionIdElement()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu2.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu2.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Meta tgt = new org.hl7.fhir.dstu2.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionIdElement()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdatedElement()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu2.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Timing tgt = new org.hl7.fhir.dstu2.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasDurationElement()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnits()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitsElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); + tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasDurationElement()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMaxElement()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitsElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) { + tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Timing.EventTimingEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.dstu2.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Age tgt = new org.hl7.fhir.dstu2.model.Age(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.dstu2.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Count tgt = new org.hl7.fhir.dstu2.model.Count(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.dstu2.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Distance tgt = new org.hl7.fhir.dstu2.model.Distance(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.dstu2.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Duration tgt = new org.hl7.fhir.dstu2.model.Duration(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.dstu2.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCodeElement()) tgt.setCurrencyElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Money tgt = new org.hl7.fhir.dstu2.model.Money(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrencyElement()) tgt.setCodeElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.SimpleQuantity tgt = new org.hl7.fhir.r5.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValueElement()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnitElement()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystemElement()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCodeElement()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu2.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu2.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu2.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu2.model.CodeType) + return convertCode((org.hl7.fhir.dstu2.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DateType) + return convertDate((org.hl7.fhir.dstu2.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu2.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu2.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IdType) return convertId((org.hl7.fhir.dstu2.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2.model.InstantType) + return convertInstant((org.hl7.fhir.dstu2.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu2.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu2.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu2.model.OidType) return convertOid((org.hl7.fhir.dstu2.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu2.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu2.model.StringType) + return convertString((org.hl7.fhir.dstu2.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu2.model.TimeType) + return convertTime((org.hl7.fhir.dstu2.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu2.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu2.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu2.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UriType) return convertUri((org.hl7.fhir.dstu2.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2.model.UuidType) + return convertUuid((org.hl7.fhir.dstu2.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu2.model.Extension) + return convertExtension((org.hl7.fhir.dstu2.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu2.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu2.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu2.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu2.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu2.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu2.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu2.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu2.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu2.model.Coding) return convertCoding((org.hl7.fhir.dstu2.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu2.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu2.model.Period) return convertPeriod((org.hl7.fhir.dstu2.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu2.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu2.model.Range) return convertRange((org.hl7.fhir.dstu2.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2.model.Ratio) return convertRatio((org.hl7.fhir.dstu2.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2.model.Reference) + return convertReference((org.hl7.fhir.dstu2.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu2.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu2.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu2.model.Signature) + return convertSignature((org.hl7.fhir.dstu2.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu2.model.Address) + return convertAddress((org.hl7.fhir.dstu2.model.Address) src); + if (src instanceof org.hl7.fhir.dstu2.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu2.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu2.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu2.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu2.model.Meta) return convertMeta((org.hl7.fhir.dstu2.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2.model.Timing) return convertTiming((org.hl7.fhir.dstu2.model.Timing) src); + if (src instanceof org.hl7.fhir.dstu2.model.Age) return convertAge((org.hl7.fhir.dstu2.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2.model.Count) return convertCount((org.hl7.fhir.dstu2.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2.model.Distance) + return convertDistance((org.hl7.fhir.dstu2.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu2.model.Duration) + return convertDuration((org.hl7.fhir.dstu2.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu2.model.Money) return convertMoney((org.hl7.fhir.dstu2.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.dstu2.model.SimpleQuantity) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r5.model.BooleanType) + return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r5.model.CodeType) return convertCode((org.hl7.fhir.r5.model.CodeType) src); + if (src instanceof org.hl7.fhir.r5.model.DateType) return convertDate((org.hl7.fhir.r5.model.DateType) src); + if (src instanceof org.hl7.fhir.r5.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r5.model.DecimalType) + return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r5.model.IdType) return convertId((org.hl7.fhir.r5.model.IdType) src); + if (src instanceof org.hl7.fhir.r5.model.InstantType) + return convertInstant((org.hl7.fhir.r5.model.InstantType) src); + if (src instanceof org.hl7.fhir.r5.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r5.model.OidType) return convertOid((org.hl7.fhir.r5.model.OidType) src); + if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r5.model.StringType) + return convertString((org.hl7.fhir.r5.model.StringType) src); + if (src instanceof org.hl7.fhir.r5.model.TimeType) return convertTime((org.hl7.fhir.r5.model.TimeType) src); + if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r5.model.IntegerType) + return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r5.model.UriType) return convertUri((org.hl7.fhir.r5.model.UriType) src); + if (src instanceof org.hl7.fhir.r5.model.UuidType) return convertUuid((org.hl7.fhir.r5.model.UuidType) src); + if (src instanceof org.hl7.fhir.r5.model.Extension) + return convertExtension((org.hl7.fhir.r5.model.Extension) src); + if (src instanceof org.hl7.fhir.r5.model.Narrative) + return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); + if (src instanceof org.hl7.fhir.r5.model.Annotation) + return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); + if (src instanceof org.hl7.fhir.r5.model.Attachment) + return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); + if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r5.model.Coding) return convertCoding((org.hl7.fhir.r5.model.Coding) src); + if (src instanceof org.hl7.fhir.r5.model.Identifier) + return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); + if (src instanceof org.hl7.fhir.r5.model.Period) return convertPeriod((org.hl7.fhir.r5.model.Period) src); + if (src instanceof org.hl7.fhir.r5.model.Quantity) return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); + if (src instanceof org.hl7.fhir.r5.model.Range) return convertRange((org.hl7.fhir.r5.model.Range) src); + if (src instanceof org.hl7.fhir.r5.model.Ratio) return convertRatio((org.hl7.fhir.r5.model.Ratio) src); + if (src instanceof org.hl7.fhir.r5.model.Reference) + return convertReference((org.hl7.fhir.r5.model.Reference) src); + if (src instanceof org.hl7.fhir.r5.model.SampledData) + return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); + if (src instanceof org.hl7.fhir.r5.model.Signature) + return convertSignature((org.hl7.fhir.r5.model.Signature) src); + if (src instanceof org.hl7.fhir.r5.model.Address) return convertAddress((org.hl7.fhir.r5.model.Address) src); + if (src instanceof org.hl7.fhir.r5.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r5.model.HumanName) + return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); + if (src instanceof org.hl7.fhir.r5.model.Meta) return convertMeta((org.hl7.fhir.r5.model.Meta) src); + if (src instanceof org.hl7.fhir.r5.model.Timing) return convertTiming((org.hl7.fhir.r5.model.Timing) src); + if (src instanceof org.hl7.fhir.r5.model.Age) return convertAge((org.hl7.fhir.r5.model.Age) src); + if (src instanceof org.hl7.fhir.r5.model.Count) return convertCount((org.hl7.fhir.r5.model.Count) src); + if (src instanceof org.hl7.fhir.r5.model.Distance) return convertDistance((org.hl7.fhir.r5.model.Distance) src); + if (src instanceof org.hl7.fhir.r5.model.Duration) return convertDuration((org.hl7.fhir.r5.model.Duration) src); + if (src instanceof org.hl7.fhir.r5.model.Money) return convertMoney((org.hl7.fhir.r5.model.Money) src); + if (src instanceof org.hl7.fhir.r5.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.r5.model.SimpleQuantity) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; + } + + public static void copyDomainResource(org.hl7.fhir.dstu2.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu2.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu2.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu2.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + public static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + public static void copyResource(org.hl7.fhir.dstu2.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + public static void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu2.model.Resource tgt) throws FHIRException { + tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public org.hl7.fhir.r5.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSearchParamType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public CodeableReference convertCodeableConceptToCodableReference(CodeableConcept src) { + CodeableReference tgt = new CodeableReference(); + tgt.setConcept(convertCodeableConcept(src)); + return tgt; + } + + static public class SourceElementComponentWrapper { + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; + } + + public String source; + public String target; + public org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent comp; + } + + public static org.hl7.fhir.r5.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.r5.model.UsageContext result = new org.hl7.fhir.r5.model.UsageContext(); + result.setValue(convertCodeableConcept(t)); + return result; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Enumerations.ConformanceResourceStatus.NULL); + break; + } + } + return tgt; + } + + static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { + CanonicalType dst = new CanonicalType(src.getReference()); + copyElement(src, dst); + return dst; + } + + static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { + Reference dst = new Reference(src.getValue()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityModeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Conformance.ConformanceEventModeEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Conformance.ConformanceEventMode.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu2.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Reference getPerformer(List practitioner) { + for (ImmunizationPerformerComponent p : practitioner) { + if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "AP")) return p.getActor(); + } + return null; + } + + static public org.hl7.fhir.r5.model.Reference getRequester(List practitioner) { + for (ImmunizationPerformerComponent p : practitioner) { + if (hasConcept(p.getFunction(), "http://hl7.org/fhir/v2/0443", "OP")) return p.getActor(); + } + return null; + } + + static public boolean hasConcept(org.hl7.fhir.r5.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.r5.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; + } + return false; + } + + static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) { + for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) { + if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true; + } + return false; + } + + public static org.hl7.fhir.r5.model.Dosage convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Dosage tgt = new org.hl7.fhir.r5.model.Dosage(); + copyElement(src, tgt); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSiteCodeableConcept()) tgt.setSite(convertCodeableConcept(src.getSiteCodeableConcept())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose() || src.hasRate()) { + DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); + if (src.hasDose()) dr.setDose(convertType(src.getDose())); + if (src.hasRate()) dr.setRate(convertType(src.getRate())); + } + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent convertMedicationOrderDosageInstructionComponent(org.hl7.fhir.r5.model.Dosage src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent tgt = new org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent(); + copyElement(src, tgt); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertType(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) + tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) + tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSlotStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Slot.SlotStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.NULL); + } else { + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSlotStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Slot.SlotStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + } else { + switch (src.getValue()) { + case BUSY: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSY); + break; + case FREE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.FREE); + break; + case BUSYUNAVAILABLE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYUNAVAILABLE); + break; + case BUSYTENTATIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.BUSYTENTATIVE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.Slot.SlotStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.NULL); + } else { + switch (src.getValue()) { + case REQUESTED: + tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.ACTIVE); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case FAILED: + tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2.model.Enumeration convertSupplyRequestStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.Enumeration tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); + VersionConvertor_10_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + } else { + switch (src.getValue()) { + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); + break; + case COMPLETED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); + break; + case CANCELLED: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent convertCodeSystem(org.hl7.fhir.r5.model.CodeSystem src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetCodeSystemComponent(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setSystemElement(convertUri(src.getUrlElement())); + if (src.hasVersionElement()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCaseSensitiveElement()) tgt.setCaseSensitiveElement(convertBoolean(src.getCaseSensitiveElement())); + for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent(); + copyElement(src, tgt); + tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); + if (src.hasCode()) tgt.setCode(src.getCode()); + if (src.hasDefinition()) tgt.setDefinition(src.getDefinition()); + if (src.hasDisplay()) tgt.setDisplay(src.getDisplay()); + for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc)); + for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) + tgt.addDesignation(convertCodeSystemDesignation(cc)); + return tgt; + } + + public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertCodeSystemDesignation(ConceptDefinitionDesignationComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUse(convertCoding(src.getUse())); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + if (src.hasValue()) tgt.setValue(src.getValue()); + return tgt; + } + + static public boolean isJurisdiction(CodeableConcept t) { + return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); + } + + public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src, VersionConvertorAdvisor50 advisor) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2.model.Parameters) + return Parameters10_50.convertParameters((org.hl7.fhir.dstu2.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu2.model.Appointment) + return Appointment10_50.convertAppointment((org.hl7.fhir.dstu2.model.Appointment) src); + if (src instanceof org.hl7.fhir.dstu2.model.AppointmentResponse) + return AppointmentResponse10_50.convertAppointmentResponse((org.hl7.fhir.dstu2.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.AuditEvent) + return AuditEvent10_50.convertAuditEvent((org.hl7.fhir.dstu2.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.dstu2.model.Basic) + return Basic10_50.convertBasic((org.hl7.fhir.dstu2.model.Basic) src); + if (src instanceof org.hl7.fhir.dstu2.model.Binary) + return Binary10_50.convertBinary((org.hl7.fhir.dstu2.model.Binary) src); + if (src instanceof org.hl7.fhir.dstu2.model.Bundle) + return Bundle10_50.convertBundle((org.hl7.fhir.dstu2.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu2.model.CarePlan) + return CarePlan10_50.convertCarePlan((org.hl7.fhir.dstu2.model.CarePlan) src); + if (src instanceof org.hl7.fhir.dstu2.model.Communication) + return Communication10_50.convertCommunication((org.hl7.fhir.dstu2.model.Communication) src); + if (src instanceof org.hl7.fhir.dstu2.model.CommunicationRequest) + return CommunicationRequest10_50.convertCommunicationRequest((org.hl7.fhir.dstu2.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.Composition) + return Composition10_50.convertComposition((org.hl7.fhir.dstu2.model.Composition) src); + if (src instanceof org.hl7.fhir.dstu2.model.ConceptMap) + return ConceptMap10_50.convertConceptMap((org.hl7.fhir.dstu2.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu2.model.Condition) + return Condition10_50.convertCondition((org.hl7.fhir.dstu2.model.Condition) src); + if (src instanceof org.hl7.fhir.dstu2.model.Conformance) + return Conformance10_50.convertConformance((org.hl7.fhir.dstu2.model.Conformance) src); + if (src instanceof org.hl7.fhir.dstu2.model.DataElement) + return DataElement10_50.convertDataElement((org.hl7.fhir.dstu2.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu2.model.DetectedIssue) + return DetectedIssue10_50.convertDetectedIssue((org.hl7.fhir.dstu2.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceMetric) + return DeviceMetric10_50.convertDeviceMetric((org.hl7.fhir.dstu2.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.dstu2.model.DeviceUseStatement) + return DeviceUseStatement10_50.convertDeviceUseStatement((org.hl7.fhir.dstu2.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.dstu2.model.DiagnosticReport) + return DiagnosticReport10_50.convertDiagnosticReport((org.hl7.fhir.dstu2.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.dstu2.model.DocumentReference) + return DocumentReference10_50.convertDocumentReference((org.hl7.fhir.dstu2.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.dstu2.model.Encounter) + return Encounter10_50.convertEncounter((org.hl7.fhir.dstu2.model.Encounter) src); + if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentRequest) + return EnrollmentRequest10_50.convertEnrollmentRequest((org.hl7.fhir.dstu2.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.EnrollmentResponse) + return EnrollmentResponse10_50.convertEnrollmentResponse((org.hl7.fhir.dstu2.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.EpisodeOfCare) + return EpisodeOfCare10_50.convertEpisodeOfCare((org.hl7.fhir.dstu2.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.dstu2.model.FamilyMemberHistory) + return FamilyMemberHistory10_50.convertFamilyMemberHistory((org.hl7.fhir.dstu2.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.dstu2.model.Flag) + return Flag10_50.convertFlag((org.hl7.fhir.dstu2.model.Flag) src); + if (src instanceof org.hl7.fhir.dstu2.model.Group) + return Group10_50.convertGroup((org.hl7.fhir.dstu2.model.Group) src); + if (src instanceof org.hl7.fhir.dstu2.model.HealthcareService) + return HealthcareService10_50.convertHealthcareService((org.hl7.fhir.dstu2.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.dstu2.model.ImplementationGuide) + return ImplementationGuide10_50.convertImplementationGuide((org.hl7.fhir.dstu2.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu2.model.List_) + return List10_50.convertList((org.hl7.fhir.dstu2.model.List_) src); + if (src instanceof org.hl7.fhir.dstu2.model.Location) + return Location10_50.convertLocation((org.hl7.fhir.dstu2.model.Location) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationDispense) + return MedicationDispense10_50.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) + return MedicationStatement10_50.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader) + return MessageHeader10_50.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) + return NamingSystem10_50.convertNamingSystem((org.hl7.fhir.dstu2.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu2.model.Observation) + return Observation10_50.convertObservation((org.hl7.fhir.dstu2.model.Observation) src); + if (src instanceof org.hl7.fhir.dstu2.model.OperationDefinition) + return OperationDefinition10_50.convertOperationDefinition((org.hl7.fhir.dstu2.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu2.model.OperationOutcome) + return OperationOutcome10_50.convertOperationOutcome((org.hl7.fhir.dstu2.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu2.model.Organization) + return Organization10_50.convertOrganization((org.hl7.fhir.dstu2.model.Organization) src); + if (src instanceof org.hl7.fhir.dstu2.model.Patient) + return Patient10_50.convertPatient((org.hl7.fhir.dstu2.model.Patient) src); + if (src instanceof org.hl7.fhir.dstu2.model.Person) + return Person10_50.convertPerson((org.hl7.fhir.dstu2.model.Person) src); + if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) + return Practitioner10_50.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); + if (src instanceof org.hl7.fhir.dstu2.model.Provenance) + return Provenance10_50.convertProvenance((org.hl7.fhir.dstu2.model.Provenance) src); + if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) + return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) + return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.dstu2.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu2.model.RiskAssessment) + return RiskAssessment10_50.convertRiskAssessment((org.hl7.fhir.dstu2.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.dstu2.model.Schedule) + return Schedule10_50.convertSchedule((org.hl7.fhir.dstu2.model.Schedule) src); + if (src instanceof org.hl7.fhir.dstu2.model.SearchParameter) + return SearchParameter10_50.convertSearchParameter((org.hl7.fhir.dstu2.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu2.model.Slot) + return Slot10_50.convertSlot((org.hl7.fhir.dstu2.model.Slot) src); + if (src instanceof org.hl7.fhir.dstu2.model.StructureDefinition) + return StructureDefinition10_50.convertStructureDefinition((org.hl7.fhir.dstu2.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu2.model.Substance) + return Substance10_50.convertSubstance((org.hl7.fhir.dstu2.model.Substance) src); + if (src instanceof org.hl7.fhir.dstu2.model.SupplyDelivery) + return SupplyDelivery10_50.convertSupplyDelivery((org.hl7.fhir.dstu2.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.dstu2.model.SupplyRequest) + return SupplyRequest10_50.convertSupplyRequest((org.hl7.fhir.dstu2.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.dstu2.model.TestScript) + return TestScript10_50.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu2.model.ValueSet) + return ValueSet10_50.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, VersionConvertorAdvisor50 advisor) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r5.model.Parameters) + return Parameters10_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); + if (src instanceof org.hl7.fhir.r5.model.Appointment) + return Appointment10_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); + if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) + return AppointmentResponse10_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.r5.model.AuditEvent) + return AuditEvent10_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.r5.model.Basic) + return Basic10_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); + if (src instanceof org.hl7.fhir.r5.model.Binary) + return Binary10_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); + if (src instanceof org.hl7.fhir.r5.model.Bundle) + return Bundle10_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src, advisor); + if (src instanceof org.hl7.fhir.r5.model.CarePlan) + return CarePlan10_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); + if (src instanceof org.hl7.fhir.r5.model.Communication) + return Communication10_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); + if (src instanceof org.hl7.fhir.r5.model.CommunicationRequest) + return CommunicationRequest10_50.convertCommunicationRequest((org.hl7.fhir.r5.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.r5.model.Composition) + return Composition10_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); + if (src instanceof org.hl7.fhir.r5.model.ConceptMap) + return ConceptMap10_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r5.model.Condition) + return Condition10_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); + if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) + return Conformance10_50.convertConformance((org.hl7.fhir.r5.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) + return DetectedIssue10_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceMetric) + return DeviceMetric10_50.convertDeviceMetric((org.hl7.fhir.r5.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceUseStatement) + return DeviceUseStatement10_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) + return DiagnosticReport10_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.r5.model.DocumentReference) + return DocumentReference10_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r5.model.Encounter) + return Encounter10_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); + if (src instanceof org.hl7.fhir.r5.model.EnrollmentRequest) + return EnrollmentRequest10_50.convertEnrollmentRequest((org.hl7.fhir.r5.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.r5.model.EnrollmentResponse) + return EnrollmentResponse10_50.convertEnrollmentResponse((org.hl7.fhir.r5.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) + return EpisodeOfCare10_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) + return FamilyMemberHistory10_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.r5.model.Flag) return Flag10_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); + if (src instanceof org.hl7.fhir.r5.model.Group) + return Group10_50.convertGroup((org.hl7.fhir.r5.model.Group) src); + if (src instanceof org.hl7.fhir.r5.model.HealthcareService) + return HealthcareService10_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) + return ImplementationGuide10_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r5.model.ListResource) + return List10_50.convertList((org.hl7.fhir.r5.model.ListResource) src); + if (src instanceof org.hl7.fhir.r5.model.Location) + return Location10_50.convertLocation((org.hl7.fhir.r5.model.Location) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) + return MedicationDispense10_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationUsage) + return MedicationStatement10_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationUsage) src); + if (src instanceof org.hl7.fhir.r5.model.MessageHeader) + return MessageHeader10_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.r5.model.NamingSystem) + return NamingSystem10_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r5.model.Observation) + return Observation10_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); + if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) + return OperationDefinition10_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) + return OperationOutcome10_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r5.model.Organization) + return Organization10_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); + if (src instanceof org.hl7.fhir.r5.model.Patient) + return Patient10_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); + if (src instanceof org.hl7.fhir.r5.model.Person) + return Person10_50.convertPerson((org.hl7.fhir.r5.model.Person) src); + if (src instanceof org.hl7.fhir.r5.model.Practitioner) + return Practitioner10_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); + if (src instanceof org.hl7.fhir.r5.model.Provenance) + return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); + if (src instanceof org.hl7.fhir.r5.model.Questionnaire) + return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) + return QuestionnaireResponse10_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) + return RiskAssessment10_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.r5.model.Schedule) + return Schedule10_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); + if (src instanceof org.hl7.fhir.r5.model.SearchParameter) + return SearchParameter10_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r5.model.Slot) return Slot10_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); + if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) + return StructureDefinition10_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Substance) + return Substance10_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); + if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) + return SupplyDelivery10_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r5.model.SupplyRequest) + return SupplyRequest10_50.convertSupplyRequest((org.hl7.fhir.r5.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.r5.model.TestScript) + return TestScript10_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); + if (src instanceof org.hl7.fhir.r5.model.ValueSet) + return ValueSet10_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src, advisor); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src) { + TerminologyCapabilities res = new TerminologyCapabilities(); + for (ParametersParameterComponent p : src.getParameter()) { + if (p.getName().equals("system")) res.addCodeSystem().setUri(p.getValue().primitiveValue()); + if (p.getName().equals("expansion.parameter")) + res.getExpansion().addParameter().setName(p.getValue().primitiveValue()); + } + return res; + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "Bundle", "CarePlan", "Communication", "CommunicationRequest", "Composition", "ConceptMap", "Condition", "CapabilityStatement", "DetectedIssue", "DeviceMetric", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Group", "HealthcareService", "ImplementationGuide", "ListResource", "Location", "MedicationDispense", "MedicationStatement", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "Person", "Practitioner", "Questionnaire", "QuestionnaireResponse", "RiskAssessment", "Schedule", "SearchParameter", "Slot", "StructureDefinition", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "TestScript", "ValueSet"); + } + + public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2.model.Resource src) throws FHIRException { + return convertResource(src, null); + } + + public static org.hl7.fhir.dstu2.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { + return convertResource(src, null); + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java index a6170f876..cb498e531 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java @@ -1,5 +1,15 @@ package org.hl7.fhir.convertors; +import org.hl7.fhir.convertors.conv14_30.*; +import org.hl7.fhir.dstu2016may.model.CodeableConcept; +import org.hl7.fhir.dstu3.conformance.ProfileUtilities; +import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.utilities.Utilities; + +import java.util.Collections; +import java.util.stream.Collectors; /* Copyright (c) 2011+, HL7, Inc. @@ -27,2881 +37,2543 @@ package org.hl7.fhir.convertors; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -import org.hl7.fhir.convertors.conv14_30.Bundle14_30; -import org.hl7.fhir.convertors.conv14_30.CodeSystem14_30; -import org.hl7.fhir.convertors.conv14_30.CompartmentDefinition14_30; -import org.hl7.fhir.convertors.conv14_30.ConceptMap14_30; -import org.hl7.fhir.convertors.conv14_30.Conformance14_30; -import org.hl7.fhir.convertors.conv14_30.DataElement14_30; -import org.hl7.fhir.convertors.conv14_30.ImplementationGuide14_30; -import org.hl7.fhir.convertors.conv14_30.NamingSystem14_30; -import org.hl7.fhir.convertors.conv14_30.OperationDefinition14_30; -import org.hl7.fhir.convertors.conv14_30.OperationOutcome14_30; -import org.hl7.fhir.convertors.conv14_30.Parameters14_30; -import org.hl7.fhir.convertors.conv14_30.Questionnaire14_30; -import org.hl7.fhir.convertors.conv14_30.QuestionnaireResponse14_30; -import org.hl7.fhir.convertors.conv14_30.SearchParameter14_30; -import org.hl7.fhir.convertors.conv14_30.StructureDefinition14_30; -import org.hl7.fhir.convertors.conv14_30.TestScript14_30; -import org.hl7.fhir.convertors.conv14_30.ValueSet14_30; -import org.hl7.fhir.dstu2016may.model.CodeableConcept; -import org.hl7.fhir.dstu3.conformance.ProfileUtilities; -import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent; -import org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; -import org.hl7.fhir.dstu3.model.Enumeration; -import org.hl7.fhir.dstu3.model.Timing.EventTiming; -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.utilities.Utilities; - -import java.util.Collections; -import java.util.stream.Collectors; public class VersionConvertor_14_30 { - - static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) tgt.setId(src.getId()); - for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { - if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && (!(e.getUrl().equals(VersionConvertorConstants.PROFILE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION)))) { - tgt.addExtension(convertExtension(e)); - } - } - } - - static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) tgt.setId(src.getId()); - for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { - if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - static public void copyBackboneElement(org.hl7.fhir.dstu2016may.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - static public void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.dstu2016may.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); - if (src.hasValue()) tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.dstu2016may.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Age tgt = new org.hl7.fhir.dstu2016may.model.Age(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.dstu2016may.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Annotation tgt = new org.hl7.fhir.dstu2016may.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasTextElement()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.dstu2016may.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Attachment tgt = new org.hl7.fhir.dstu2016may.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.CodeableConcept tgt = new org.hl7.fhir.dstu2016may.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.dstu2016may.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.dstu2016may.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Count tgt = new org.hl7.fhir.dstu2016may.model.Count(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.dstu2016may.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Distance tgt = new org.hl7.fhir.dstu2016may.model.Distance(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.dstu2016may.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Duration tgt = new org.hl7.fhir.dstu2016may.model.Duration(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.dstu2016may.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Money tgt = new org.hl7.fhir.dstu2016may.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.dstu2016may.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Identifier tgt = new org.hl7.fhir.dstu2016may.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.dstu2016may.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Period tgt = new org.hl7.fhir.dstu2016may.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.dstu2016may.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Range tgt = new org.hl7.fhir.dstu2016may.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.dstu2016may.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Ratio tgt = new org.hl7.fhir.dstu2016may.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.dstu2016may.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Reference tgt = new org.hl7.fhir.dstu2016may.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.dstu2016may.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.SampledData tgt = new org.hl7.fhir.dstu2016may.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasBlob()) - tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasBlob()) - tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.dstu2016may.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Address tgt = new org.hl7.fhir.dstu2016may.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressTypeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_14_30::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasName()) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertTypeRefComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_14_30::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertTypeRefComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExample().get(0).getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) { - if (src.getCode().equals("Reference")) - tgt.setTargetProfile(u.getValue()); - else - tgt.setProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) { - String s = ((org.hl7.fhir.dstu2016may.model.PrimitiveType) t.getValue()).getValue(); - tgt.setProfile(s); - } - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_14_30::convertAggregationMode) - .collect(Collectors.toList())); - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - if (src.hasTarget()) { - if (src.hasTargetProfile()) { - tgt.addProfile(src.getTargetProfile()); - } - if (src.hasProfile()) { - if (src.getCode().equals("Reference")) { - org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION); - t.setValue(new org.hl7.fhir.dstu2016may.model.StringType(src.getProfile())); - tgt.addExtension(t); - } else - tgt.addProfile(src.getProfile()); - } - } else - tgt.addProfile(src.getProfile()); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_14_30::convertAggregationMode) - .collect(Collectors.toList())); - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSet(convertType(src.getValueSet())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.HumanName tgt = new org.hl7.fhir.dstu2016may.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.HumanName.NameUseEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.dstu2016may.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCountElement(convertInteger(src.getCountElement())); - if (src.hasCountMax()) - tgt.setCountMaxElement(convertInteger(src.getCountMaxElement())); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); - if (src.hasFrequencyMax()) - tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - } - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCountElement(convertInteger(src.getCountElement())); - if (src.hasCountMax()) - tgt.setCountMaxElement(convertInteger(src.getCountMaxElement())); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); - if (src.hasFrequencyMax()) - tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu2016may.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2016may.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2016may.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu2016may.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu2016may.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeType) - return convertCode((org.hl7.fhir.dstu2016may.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DateType) - return convertDate((org.hl7.fhir.dstu2016may.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu2016may.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu2016may.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.IdType) - return convertId((org.hl7.fhir.dstu2016may.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.InstantType) - return convertInstant((org.hl7.fhir.dstu2016may.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu2016may.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OidType) - return convertOid((org.hl7.fhir.dstu2016may.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu2016may.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StringType) - return convertString((org.hl7.fhir.dstu2016may.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.TimeType) - return convertTime((org.hl7.fhir.dstu2016may.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu2016may.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu2016may.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UriType) - return convertUri((org.hl7.fhir.dstu2016may.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UuidType) - return convertUuid((org.hl7.fhir.dstu2016may.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Extension) - return convertExtension((org.hl7.fhir.dstu2016may.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu2016may.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Age) - return convertAge((org.hl7.fhir.dstu2016may.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu2016may.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu2016may.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu2016may.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Coding) - return convertCoding((org.hl7.fhir.dstu2016may.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Count) - return convertCount((org.hl7.fhir.dstu2016may.model.Count) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Distance) - return convertDistance((org.hl7.fhir.dstu2016may.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Duration) - return convertDuration((org.hl7.fhir.dstu2016may.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu2016may.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Money) - return convertMoney((org.hl7.fhir.dstu2016may.model.Money) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Period) - return convertPeriod((org.hl7.fhir.dstu2016may.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu2016may.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Range) - return convertRange((org.hl7.fhir.dstu2016may.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2016may.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Reference) - return convertReference((org.hl7.fhir.dstu2016may.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu2016may.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Signature) - return convertSignature((org.hl7.fhir.dstu2016may.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Address) - return convertAddress((org.hl7.fhir.dstu2016may.model.Address) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu2016may.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.dstu2016may.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu2016may.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Meta) - return convertMeta((org.hl7.fhir.dstu2016may.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Timing) - return convertTiming((org.hl7.fhir.dstu2016may.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeType) - return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateType) - return convertDate((org.hl7.fhir.dstu3.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IdType) - return convertId((org.hl7.fhir.dstu3.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu3.model.InstantType) - return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu3.model.OidType) - return convertOid((org.hl7.fhir.dstu3.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.StringType) - return convertString((org.hl7.fhir.dstu3.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu3.model.TimeType) - return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UriType) - return convertUri((org.hl7.fhir.dstu3.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UuidType) - return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.Extension) - return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu3.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu3.model.Age) - return convertAge((org.hl7.fhir.dstu3.model.Age) src); - if (src instanceof org.hl7.fhir.dstu3.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu3.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu3.model.Coding) - return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu3.model.Count) - return convertCount((org.hl7.fhir.dstu3.model.Count) src); - if (src instanceof org.hl7.fhir.dstu3.model.Distance) - return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Duration) - return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu3.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu3.model.Money) - return convertMoney((org.hl7.fhir.dstu3.model.Money) src); - if (src instanceof org.hl7.fhir.dstu3.model.Period) - return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); - if (src instanceof org.hl7.fhir.dstu3.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Range) - return convertRange((org.hl7.fhir.dstu3.model.Range) src); - if (src instanceof org.hl7.fhir.dstu3.model.Ratio) - return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu3.model.Reference) - return convertReference((org.hl7.fhir.dstu3.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu3.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu3.model.Signature) - return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu3.model.Address) - return convertAddress((org.hl7.fhir.dstu3.model.Address) src); - if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu3.model.Meta) - return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu3.model.Timing) - return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); - } - - static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu3.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu3.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu3.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); - } - - static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - public static org.hl7.fhir.dstu3.model.Binary convertBinary(org.hl7.fhir.dstu2016may.model.Binary src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Binary tgt = new org.hl7.fhir.dstu3.model.Binary(); - copyResource(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasContentElement()) - tgt.setContentElement(convertBase64Binary(src.getContentElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Binary convertBinary(org.hl7.fhir.dstu3.model.Binary src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Binary tgt = new org.hl7.fhir.dstu2016may.model.Binary(); - copyResource(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasContentElement()) - tgt.setContentElement(convertBase64Binary(src.getContentElement())); - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); - break; - } - return tgt; - } - - static public boolean isJurisdiction(CodeableConcept t) { - return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); - } - - public static org.hl7.fhir.dstu3.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2016may.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.dstu3.model.UsageContext result = new org.hl7.fhir.dstu3.model.UsageContext(); - result.setValue(convertCodeableConcept(t)); - return result; - } - - static public class SourceElementComponentWrapper { - - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - public String source; - - public String target; - - public org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent comp; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_14_30.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) - return Parameters14_30.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Bundle) - return Bundle14_30.convertBundle((org.hl7.fhir.dstu2016may.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeSystem) - return CodeSystem14_30.convertCodeSystem((org.hl7.fhir.dstu2016may.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CompartmentDefinition) - return CompartmentDefinition14_30.convertCompartmentDefinition((org.hl7.fhir.dstu2016may.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ConceptMap) - return ConceptMap14_30.convertConceptMap((org.hl7.fhir.dstu2016may.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Conformance) - return Conformance14_30.convertConformance((org.hl7.fhir.dstu2016may.model.Conformance) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DataElement) - return DataElement14_30.convertDataElement((org.hl7.fhir.dstu2016may.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ImplementationGuide) - return ImplementationGuide14_30.convertImplementationGuide((org.hl7.fhir.dstu2016may.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.NamingSystem) - return NamingSystem14_30.convertNamingSystem((org.hl7.fhir.dstu2016may.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OperationDefinition) - return OperationDefinition14_30.convertOperationDefinition((org.hl7.fhir.dstu2016may.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OperationOutcome) - return OperationOutcome14_30.convertOperationOutcome((org.hl7.fhir.dstu2016may.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Questionnaire) - return Questionnaire14_30.convertQuestionnaire((org.hl7.fhir.dstu2016may.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) - return QuestionnaireResponse14_30.convertQuestionnaireResponse((org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.SearchParameter) - return SearchParameter14_30.convertSearchParameter((org.hl7.fhir.dstu2016may.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StructureDefinition) - return StructureDefinition14_30.convertStructureDefinition((org.hl7.fhir.dstu2016may.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.TestScript) - return TestScript14_30.convertTestScript((org.hl7.fhir.dstu2016may.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) - return ValueSet14_30.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Parameters) - return Parameters14_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu3.model.Bundle) - return Bundle14_30.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) - return CodeSystem14_30.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) - return CompartmentDefinition14_30.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) - return ConceptMap14_30.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) - return Conformance14_30.convertConformance((org.hl7.fhir.dstu3.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DataElement) - return DataElement14_30.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) - return ImplementationGuide14_30.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) - return NamingSystem14_30.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) - return OperationDefinition14_30.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) - return OperationOutcome14_30.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) - return Questionnaire14_30.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) - return QuestionnaireResponse14_30.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) - return SearchParameter14_30.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) - return StructureDefinition14_30.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.TestScript) - return TestScript14_30.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) - return ValueSet14_30.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "Bundle", "CodeSystem", "CompartmentDefinition", "ConceptMap", "CapabilityStatement", "DataElement", "ImplementationGuide", "NamingSystem", "OperationDefinition", "OperationOutcome", "Questionnaire", "QuestionnaireResponse", "SearchParameter", "StructureDefinition", "TestScript", "ValueSet"); - } + static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... exemptExtensions) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { + if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && (!(e.getUrl().equals(VersionConvertorConstants.PROFILE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION)))) { + tgt.addExtension(convertExtension(e)); + } + } + } + + static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { + if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + static public void copyBackboneElement(org.hl7.fhir.dstu2016may.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + static public void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.dstu2016may.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu3.model.BooleanType tgt = new org.hl7.fhir.dstu3.model.BooleanType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.CodeType tgt = new org.hl7.fhir.dstu3.model.CodeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = new org.hl7.fhir.dstu3.model.DateType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateTimeType tgt = new org.hl7.fhir.dstu3.model.DateTimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu3.model.InstantType tgt = new org.hl7.fhir.dstu3.model.InstantType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IntegerType tgt = new org.hl7.fhir.dstu3.model.IntegerType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu3.model.MarkdownType tgt = new org.hl7.fhir.dstu3.model.MarkdownType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.OidType tgt = new org.hl7.fhir.dstu3.model.OidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.PositiveIntType tgt = new org.hl7.fhir.dstu3.model.PositiveIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu3.model.StringType tgt = new org.hl7.fhir.dstu3.model.StringType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.TimeType tgt = new org.hl7.fhir.dstu3.model.TimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UnsignedIntType tgt = new org.hl7.fhir.dstu3.model.UnsignedIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UriType tgt = new org.hl7.fhir.dstu3.model.UriType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UuidType tgt = new org.hl7.fhir.dstu3.model.UuidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.dstu2016may.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Age tgt = new org.hl7.fhir.dstu2016may.model.Age(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.dstu2016may.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Annotation tgt = new org.hl7.fhir.dstu2016may.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasTextElement()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.dstu2016may.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Attachment tgt = new org.hl7.fhir.dstu2016may.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.CodeableConcept tgt = new org.hl7.fhir.dstu2016may.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.dstu2016may.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.dstu2016may.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Count tgt = new org.hl7.fhir.dstu2016may.model.Count(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.dstu2016may.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Distance tgt = new org.hl7.fhir.dstu2016may.model.Distance(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.dstu2016may.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Duration tgt = new org.hl7.fhir.dstu2016may.model.Duration(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.dstu2016may.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Money tgt = new org.hl7.fhir.dstu2016may.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.dstu2016may.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Identifier tgt = new org.hl7.fhir.dstu2016may.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.dstu2016may.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Period tgt = new org.hl7.fhir.dstu2016may.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.dstu2016may.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Range tgt = new org.hl7.fhir.dstu2016may.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.dstu2016may.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Ratio tgt = new org.hl7.fhir.dstu2016may.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.dstu2016may.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Reference tgt = new org.hl7.fhir.dstu2016may.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.dstu2016may.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.SampledData tgt = new org.hl7.fhir.dstu2016may.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasBlob()) tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasBlob()) tgt.setBlobElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.dstu2016may.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Address tgt = new org.hl7.fhir.dstu2016may.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressTypeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_14_30::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasName()) tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertTypeRefComponent(t)); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_14_30::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertTypeRefComponent(t)); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.setExample(convertType(src.getExample().get(0).getValue())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) { + if (src.getCode().equals("Reference")) tgt.setTargetProfile(u.getValue()); + else tgt.setProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) { + String s = ((org.hl7.fhir.dstu2016may.model.PrimitiveType) t.getValue()).getValue(); + tgt.setProfile(s); + } + tgt.setAggregation(src.getAggregation().stream().map(VersionConvertor_14_30::convertAggregationMode).collect(Collectors.toList())); + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + if (src.hasTarget()) { + if (src.hasTargetProfile()) { + tgt.addProfile(src.getTargetProfile()); + } + if (src.hasProfile()) { + if (src.getCode().equals("Reference")) { + org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION); + t.setValue(new org.hl7.fhir.dstu2016may.model.StringType(src.getProfile())); + tgt.addExtension(t); + } else tgt.addProfile(src.getProfile()); + } + } else tgt.addProfile(src.getProfile()); + tgt.setAggregation(src.getAggregation().stream().map(VersionConvertor_14_30::convertAggregationMode).collect(Collectors.toList())); + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) tgt.setValueSet(convertType(src.getValueSet())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.HumanName tgt = new org.hl7.fhir.dstu2016may.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.HumanName.NameUseEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.dstu2016may.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCountElement(convertInteger(src.getCountElement())); + if (src.hasCountMax()) tgt.setCountMaxElement(convertInteger(src.getCountMaxElement())); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); + if (src.hasFrequencyMax()) tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) { + tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + } + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCountElement(convertInteger(src.getCountElement())); + if (src.hasCountMax()) tgt.setCountMaxElement(convertInteger(src.getCountMaxElement())); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequencyElement(convertInteger(src.getFrequencyElement())); + if (src.hasFrequencyMax()) tgt.setFrequencyMaxElement(convertInteger(src.getFrequencyMaxElement())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) { + tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + } + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu2016may.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2016may.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2016may.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu2016may.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu2016may.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeType) + return convertCode((org.hl7.fhir.dstu2016may.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DateType) + return convertDate((org.hl7.fhir.dstu2016may.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu2016may.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu2016may.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.IdType) + return convertId((org.hl7.fhir.dstu2016may.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.InstantType) + return convertInstant((org.hl7.fhir.dstu2016may.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu2016may.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OidType) + return convertOid((org.hl7.fhir.dstu2016may.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu2016may.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StringType) + return convertString((org.hl7.fhir.dstu2016may.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.TimeType) + return convertTime((org.hl7.fhir.dstu2016may.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu2016may.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu2016may.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UriType) + return convertUri((org.hl7.fhir.dstu2016may.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UuidType) + return convertUuid((org.hl7.fhir.dstu2016may.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Extension) + return convertExtension((org.hl7.fhir.dstu2016may.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu2016may.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Age) return convertAge((org.hl7.fhir.dstu2016may.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu2016may.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu2016may.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu2016may.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Coding) + return convertCoding((org.hl7.fhir.dstu2016may.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Count) + return convertCount((org.hl7.fhir.dstu2016may.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Distance) + return convertDistance((org.hl7.fhir.dstu2016may.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Duration) + return convertDuration((org.hl7.fhir.dstu2016may.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu2016may.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Money) + return convertMoney((org.hl7.fhir.dstu2016may.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Period) + return convertPeriod((org.hl7.fhir.dstu2016may.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu2016may.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Range) + return convertRange((org.hl7.fhir.dstu2016may.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Ratio) + return convertRatio((org.hl7.fhir.dstu2016may.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Reference) + return convertReference((org.hl7.fhir.dstu2016may.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu2016may.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Signature) + return convertSignature((org.hl7.fhir.dstu2016may.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Address) + return convertAddress((org.hl7.fhir.dstu2016may.model.Address) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu2016may.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.dstu2016may.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu2016may.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Meta) + return convertMeta((org.hl7.fhir.dstu2016may.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Timing) + return convertTiming((org.hl7.fhir.dstu2016may.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeType) return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateType) return convertDate((org.hl7.fhir.dstu3.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IdType) return convertId((org.hl7.fhir.dstu3.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu3.model.InstantType) + return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu3.model.OidType) return convertOid((org.hl7.fhir.dstu3.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.StringType) + return convertString((org.hl7.fhir.dstu3.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu3.model.TimeType) return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UriType) return convertUri((org.hl7.fhir.dstu3.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UuidType) return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.Extension) + return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu3.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu3.model.Age) return convertAge((org.hl7.fhir.dstu3.model.Age) src); + if (src instanceof org.hl7.fhir.dstu3.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu3.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu3.model.Coding) return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu3.model.Count) return convertCount((org.hl7.fhir.dstu3.model.Count) src); + if (src instanceof org.hl7.fhir.dstu3.model.Distance) + return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Duration) + return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu3.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu3.model.Money) return convertMoney((org.hl7.fhir.dstu3.model.Money) src); + if (src instanceof org.hl7.fhir.dstu3.model.Period) return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); + if (src instanceof org.hl7.fhir.dstu3.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu3.model.Range) return convertRange((org.hl7.fhir.dstu3.model.Range) src); + if (src instanceof org.hl7.fhir.dstu3.model.Ratio) return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu3.model.Reference) + return convertReference((org.hl7.fhir.dstu3.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu3.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu3.model.Signature) + return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu3.model.Address) return convertAddress((org.hl7.fhir.dstu3.model.Address) src); + if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu3.model.Meta) return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu3.model.Timing) return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) + tgt.addModifierExtension(convertExtension(t)); + } + + static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu3.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu3.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu3.model.Extension t : src.getModifierExtension()) + tgt.addModifierExtension(convertExtension(t)); + } + + static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + public static org.hl7.fhir.dstu3.model.Binary convertBinary(org.hl7.fhir.dstu2016may.model.Binary src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Binary tgt = new org.hl7.fhir.dstu3.model.Binary(); + copyResource(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasContentElement()) tgt.setContentElement(convertBase64Binary(src.getContentElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Binary convertBinary(org.hl7.fhir.dstu3.model.Binary src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Binary tgt = new org.hl7.fhir.dstu2016may.model.Binary(); + copyResource(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasContentElement()) tgt.setContentElement(convertBase64Binary(src.getContentElement())); + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); + break; + } + } + return tgt; + } + + static public boolean isJurisdiction(CodeableConcept t) { + return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); + } + + public static org.hl7.fhir.dstu3.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2016may.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.dstu3.model.UsageContext result = new org.hl7.fhir.dstu3.model.UsageContext(); + result.setValue(convertCodeableConcept(t)); + return result; + } + + static public class SourceElementComponentWrapper { + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; + } + + public String source; + public String target; + public org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent comp; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_14_30.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) + return Parameters14_30.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Bundle) + return Bundle14_30.convertBundle((org.hl7.fhir.dstu2016may.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeSystem) + return CodeSystem14_30.convertCodeSystem((org.hl7.fhir.dstu2016may.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CompartmentDefinition) + return CompartmentDefinition14_30.convertCompartmentDefinition((org.hl7.fhir.dstu2016may.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ConceptMap) + return ConceptMap14_30.convertConceptMap((org.hl7.fhir.dstu2016may.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Conformance) + return Conformance14_30.convertConformance((org.hl7.fhir.dstu2016may.model.Conformance) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DataElement) + return DataElement14_30.convertDataElement((org.hl7.fhir.dstu2016may.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ImplementationGuide) + return ImplementationGuide14_30.convertImplementationGuide((org.hl7.fhir.dstu2016may.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.NamingSystem) + return NamingSystem14_30.convertNamingSystem((org.hl7.fhir.dstu2016may.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OperationDefinition) + return OperationDefinition14_30.convertOperationDefinition((org.hl7.fhir.dstu2016may.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OperationOutcome) + return OperationOutcome14_30.convertOperationOutcome((org.hl7.fhir.dstu2016may.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Questionnaire) + return Questionnaire14_30.convertQuestionnaire((org.hl7.fhir.dstu2016may.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) + return QuestionnaireResponse14_30.convertQuestionnaireResponse((org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.SearchParameter) + return SearchParameter14_30.convertSearchParameter((org.hl7.fhir.dstu2016may.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StructureDefinition) + return StructureDefinition14_30.convertStructureDefinition((org.hl7.fhir.dstu2016may.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.TestScript) + return TestScript14_30.convertTestScript((org.hl7.fhir.dstu2016may.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) + return ValueSet14_30.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu3.model.Parameters) + return Parameters14_30.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu3.model.Bundle) + return Bundle14_30.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) + return CodeSystem14_30.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) + return CompartmentDefinition14_30.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) + return ConceptMap14_30.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) + return Conformance14_30.convertConformance((org.hl7.fhir.dstu3.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DataElement) + return DataElement14_30.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) + return ImplementationGuide14_30.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) + return NamingSystem14_30.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) + return OperationDefinition14_30.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) + return OperationOutcome14_30.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) + return Questionnaire14_30.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) + return QuestionnaireResponse14_30.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) + return SearchParameter14_30.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) + return StructureDefinition14_30.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.TestScript) + return TestScript14_30.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) + return ValueSet14_30.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "Bundle", "CodeSystem", "CompartmentDefinition", "ConceptMap", "CapabilityStatement", "DataElement", "ImplementationGuide", "NamingSystem", "OperationDefinition", "OperationOutcome", "Questionnaire", "QuestionnaireResponse", "SearchParameter", "StructureDefinition", "TestScript", "ValueSet"); + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java index 96b92e16c..e674067e4 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java @@ -1,5 +1,15 @@ package org.hl7.fhir.convertors; +import org.hl7.fhir.convertors.conv14_40.*; +import org.hl7.fhir.dstu2016may.model.CodeableConcept; +import org.hl7.fhir.dstu2016may.model.Reference; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r4.conformance.ProfileUtilities; +import org.hl7.fhir.r4.model.CanonicalType; +import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; +import org.hl7.fhir.utilities.Utilities; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -31,3083 +41,2708 @@ import java.util.stream.Collectors; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -import org.hl7.fhir.convertors.conv14_40.Bundle14_40; -import org.hl7.fhir.convertors.conv14_40.CodeSystem14_40; -import org.hl7.fhir.convertors.conv14_40.CompartmentDefinition14_40; -import org.hl7.fhir.convertors.conv14_40.ConceptMap14_40; -import org.hl7.fhir.convertors.conv14_40.Conformance14_40; -import org.hl7.fhir.convertors.conv14_40.DataElement14_40; -import org.hl7.fhir.convertors.conv14_40.ImplementationGuide14_40; -import org.hl7.fhir.convertors.conv14_40.NamingSystem14_40; -import org.hl7.fhir.convertors.conv14_40.OperationDefinition14_40; -import org.hl7.fhir.convertors.conv14_40.OperationOutcome14_40; -import org.hl7.fhir.convertors.conv14_40.Parameters14_40; -import org.hl7.fhir.convertors.conv14_40.Questionnaire14_40; -import org.hl7.fhir.convertors.conv14_40.QuestionnaireResponse14_40; -import org.hl7.fhir.convertors.conv14_40.SearchParameter14_40; -import org.hl7.fhir.convertors.conv14_40.StructureDefinition14_40; -import org.hl7.fhir.convertors.conv14_40.StructureMap14_40; -import org.hl7.fhir.convertors.conv14_40.ValueSet14_40; -import org.hl7.fhir.dstu2016may.model.CodeableConcept; -import org.hl7.fhir.dstu2016may.model.Reference; -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r4.conformance.ProfileUtilities; -import org.hl7.fhir.r4.model.CanonicalType; -import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent; -import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; -import org.hl7.fhir.r4.model.Enumeration; -import org.hl7.fhir.r4.model.Timing.EventTiming; -import org.hl7.fhir.utilities.Utilities; public class VersionConvertor_14_40 { + static public List CANONICAL_URLS = new ArrayList(); - static public List CANONICAL_URLS = new ArrayList(); + static { + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + } - static { - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... exemptExtensions) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { + if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && (!(e.getUrl().equals(VersionConvertorConstants.PROFILE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION)))) { + tgt.addExtension(convertExtension(e)); + } } + } - static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { - if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && (!(e.getUrl().equals(VersionConvertorConstants.PROFILE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || e.getUrl().equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION)))) { - tgt.addExtension(convertExtension(e)); - } + static public void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + static public void copyBackboneElement(org.hl7.fhir.dstu2016may.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + static public void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.dstu2016may.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { + org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { + org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { + org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { + org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { + org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { + org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2016may.model.Reference) + tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) + tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu2016may.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Age tgt = new org.hl7.fhir.dstu2016may.model.Age(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu2016may.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Annotation tgt = new org.hl7.fhir.dstu2016may.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu2016may.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Attachment tgt = new org.hl7.fhir.dstu2016may.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.CodeableConcept tgt = new org.hl7.fhir.dstu2016may.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu2016may.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu2016may.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Count tgt = new org.hl7.fhir.dstu2016may.model.Count(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu2016may.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Distance tgt = new org.hl7.fhir.dstu2016may.model.Distance(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu2016may.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Duration tgt = new org.hl7.fhir.dstu2016may.model.Duration(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu2016may.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCode()) tgt.setCurrencyElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Money tgt = new org.hl7.fhir.dstu2016may.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrency()) tgt.setCodeElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu2016may.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Identifier tgt = new org.hl7.fhir.dstu2016may.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu2016may.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Period tgt = new org.hl7.fhir.dstu2016may.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu2016may.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Range tgt = new org.hl7.fhir.dstu2016may.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu2016may.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Ratio tgt = new org.hl7.fhir.dstu2016may.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu2016may.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Reference tgt = new org.hl7.fhir.dstu2016may.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu2016may.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.SampledData tgt = new org.hl7.fhir.dstu2016may.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); + else tgt.setWho(convertReference(src.getWhoReference())); + if (src.hasContentType()) tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); + if (src.hasBlob()) tgt.setDataElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasSigFormat()) tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); + if (src.hasData()) tgt.setBlobElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu2016may.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Address tgt = new org.hl7.fhir.dstu2016may.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressTypeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_14_40::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasName()) tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (tgt.getIsModifier()) { + String reason = org.hl7.fhir.dstu2016may.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); + if (Utilities.noString(reason)) reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; + tgt.setIsModifierReason(reason); + } + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_14_40::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.setExample(convertType(src.getExample().get(0).getValue())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) + org.hl7.fhir.dstu2016may.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + org.hl7.fhir.dstu2016may.model.ElementDefinition slicingElement = context.get(pos); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) { + boolean isExists = false; + if (!t.asStringValue().contains("@")) { + int slices = 0; + boolean existsSlicePresent = false; + boolean notExistsSlicePresent = false; + String existsPath = slicingElement.getPath() + "." + t.asStringValue(); + for (int i = pos + 1; i < context.size(); i++) { + org.hl7.fhir.dstu2016may.model.ElementDefinition e = context.get(i); + if (e.getPath().equals(slicingElement.getPath())) slices++; + else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) break; + else if (e.getPath().equals(existsPath)) { + if (e.hasMin() && e.getMin() > 0 && !e.hasFixed()) existsSlicePresent = true; + else if (e.hasMax() && e.getMax().equals("0")) notExistsSlicePresent = true; + } } - } - - static public void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - static public void copyBackboneElement(org.hl7.fhir.dstu2016may.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - static public void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.dstu2016may.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = new org.hl7.fhir.r4.model.BooleanType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = new org.hl7.fhir.r4.model.CodeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = new org.hl7.fhir.r4.model.DateType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = new org.hl7.fhir.r4.model.DateTimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = new org.hl7.fhir.r4.model.IdType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = new org.hl7.fhir.r4.model.InstantType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = new org.hl7.fhir.r4.model.IntegerType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = new org.hl7.fhir.r4.model.MarkdownType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = new org.hl7.fhir.r4.model.OidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = new org.hl7.fhir.r4.model.PositiveIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = new org.hl7.fhir.r4.model.TimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = new org.hl7.fhir.r4.model.UnsignedIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = new org.hl7.fhir.r4.model.UriType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = new org.hl7.fhir.r4.model.UuidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2016may.model.Reference) - tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) - tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu2016may.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Age tgt = new org.hl7.fhir.dstu2016may.model.Age(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu2016may.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Annotation tgt = new org.hl7.fhir.dstu2016may.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu2016may.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Attachment tgt = new org.hl7.fhir.dstu2016may.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.CodeableConcept tgt = new org.hl7.fhir.dstu2016may.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu2016may.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu2016may.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Count tgt = new org.hl7.fhir.dstu2016may.model.Count(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu2016may.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Distance tgt = new org.hl7.fhir.dstu2016may.model.Distance(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu2016may.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Duration tgt = new org.hl7.fhir.dstu2016may.model.Duration(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu2016may.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCode()) - tgt.setCurrencyElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Money tgt = new org.hl7.fhir.dstu2016may.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrency()) - tgt.setCodeElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu2016may.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Identifier tgt = new org.hl7.fhir.dstu2016may.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu2016may.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Period tgt = new org.hl7.fhir.dstu2016may.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu2016may.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Range tgt = new org.hl7.fhir.dstu2016may.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu2016may.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Ratio tgt = new org.hl7.fhir.dstu2016may.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu2016may.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Reference tgt = new org.hl7.fhir.dstu2016may.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu2016may.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.SampledData tgt = new org.hl7.fhir.dstu2016may.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWhoUriType()) - tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); - else - tgt.setWho(convertReference(src.getWhoReference())); - if (src.hasContentType()) - tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); - if (src.hasBlob()) - tgt.setDataElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasSigFormat()) - tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); - if (src.hasData()) - tgt.setBlobElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu2016may.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Address tgt = new org.hl7.fhir.dstu2016may.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressTypeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition src, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_14_40::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasName()) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (tgt.getIsModifier()) { - String reason = org.hl7.fhir.dstu2016may.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); - if (Utilities.noString(reason)) - reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; - tgt.setIsModifierReason(reason); - } - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_14_40::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExample().get(0).getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) - org.hl7.fhir.dstu2016may.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - org.hl7.fhir.dstu2016may.model.ElementDefinition slicingElement = context.get(pos); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) { - boolean isExists = false; - if (!t.asStringValue().contains("@")) { - int slices = 0; - boolean existsSlicePresent = false; - boolean notExistsSlicePresent = false; - String existsPath = slicingElement.getPath() + "." + t.asStringValue(); - for (int i = pos + 1; i < context.size(); i++) { - org.hl7.fhir.dstu2016may.model.ElementDefinition e = context.get(i); - if (e.getPath().equals(slicingElement.getPath())) - slices++; - else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) - break; - else if (e.getPath().equals(existsPath)) { - if (e.hasMin() && e.getMin() > 0 && !e.hasFixed()) - existsSlicePresent = true; - else if (e.hasMax() && e.getMax().equals("0")) - notExistsSlicePresent = true; - } - } - isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); - } - tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); - } - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - static public void convertTypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = null; - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : list) if (t.getCode().equals(src.getCode())) - tgt = t; - if (tgt == null) { - tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - } - if (tgt.hasTarget()) { - for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) { - if (src.getCode().equals("Reference")) - tgt.addTargetProfile(u.getValue()); - else - tgt.addProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) { - String s = ((org.hl7.fhir.dstu2016may.model.PrimitiveType) t.getValue()).getValue(); - tgt.addProfile(s); - } - } else { - for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2016may.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.r4.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregation(a.getValue())); - } - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - } - - public static void convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - list.add(tgt); - if (src.hasTarget()) { - for (org.hl7.fhir.r4.model.UriType u : src.getTargetProfile()) { - tgt.addProfile(u.getValue()); - String baseName = u.getValue().toLowerCase(); - if (baseName.contains("reference") && !baseName.contains("documentreference")) - throw new Error("2016May Target profile contains the word 'reference':" + u); - } - for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { - if (src.getCode().equals("Reference")) { - org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION); - t.setValue(convertType(u)); - tgt.addExtension(t); - } else - tgt.addProfile(u.getValue()); - } - } else { - for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { - tgt.addProfile(u.getValue()); - } - } - for (org.hl7.fhir.r4.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.dstu2016may.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregation(a.getValue())); - } - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - } - - static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpression(convertToR4Expression(src.getExpression())); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpression(convertTo2016MayExpression(src.getExpression())); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static String convertToR4Expression(String oldExpression) { - String pass1 = oldExpression.replaceAll("\\$context", "%context").replaceAll("\\$resource", "%resource").replaceAll("code\\+profile", "code&profile").replaceAll("path\\+'\\.'", "path&'.'").replaceAll("fullUrl\\+resource", "fullUrl&resource"); - String pass2 = pass1; - if (pass1.endsWith(".distinct()")) - pass2 = pass1.substring(0, pass2.length() - 11) + ".isDistinct()"; - String pass3 = pass2; - if (pass2.endsWith(".empty() or (type.count() = 1)")) - pass3 = pass2.substring(0, pass2.length() - 30) + ".empty() or (type.count() <= 1)"; - String pass4 = pass3; - if (pass3.equals("duration >= 0")) - pass4 = "duration.exists() implies duration >= 0"; - else if (pass3.equals("period >= 0")) - pass4 = "period.exists() implies period >= 0"; - else if (pass3.equals("fullUrl.empty() xor resource")) - pass4 = "fullUrl.empty() xor resource.exists()"; - return pass4; - } - - public static String convertTo2016MayExpression(String newExpression) { - String pass1 = newExpression.replaceAll("%context", "\\$context").replaceAll("%resource", "\\$resource").replaceAll("code&profile", "code+profile").replaceAll("path&'\\.'", "path+'.'").replaceAll("fullUrl%resource", "fullUrl+resource"); - String pass2 = pass1; - if (pass1.endsWith(".isDistinct()")) - pass2 = pass1.substring(0, pass1.length() - 13) + ".distinct()"; - String pass3 = pass2; - if (pass2.endsWith(".empty() or (type.count() <= 1)")) - pass3 = pass2.substring(0, pass2.length() - 31) + ".empty() or (type.count() = 1)"; - String pass4 = pass3; - if (pass3.equals("duration.exists() implies duration >= 0")) - pass4 = "duration >= 0"; - else if (pass3.equals("period.exists() implies period >= 0")) - pass4 = "period >= 0"; - else if (pass3.equals("fullUrl.empty() xor resource.exists()")) - pass4 = "fullUrl.empty() xor resource"; - return pass4; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - org.hl7.fhir.r4.model.Type t = convertType(src.getValueSet()); - if (t instanceof org.hl7.fhir.r4.model.Reference) - tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); - else - tgt.setValueSet(t.primitiveValue()); - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.Reference(src.getValueSet())); - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertBindingStrength(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.HumanName tgt = new org.hl7.fhir.dstu2016may.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.HumanName.NameUseEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu2016may.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - } - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2016may.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2016may.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2016may.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu2016may.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu2016may.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeType) - return convertCode((org.hl7.fhir.dstu2016may.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DateType) - return convertDate((org.hl7.fhir.dstu2016may.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu2016may.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu2016may.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.IdType) - return convertId((org.hl7.fhir.dstu2016may.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.InstantType) - return convertInstant((org.hl7.fhir.dstu2016may.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu2016may.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OidType) - return convertOid((org.hl7.fhir.dstu2016may.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu2016may.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StringType) - return convertString((org.hl7.fhir.dstu2016may.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.TimeType) - return convertTime((org.hl7.fhir.dstu2016may.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu2016may.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu2016may.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UriType) - return convertUri((org.hl7.fhir.dstu2016may.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UuidType) - return convertUuid((org.hl7.fhir.dstu2016may.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Extension) - return convertExtension((org.hl7.fhir.dstu2016may.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu2016may.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Age) - return convertAge((org.hl7.fhir.dstu2016may.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu2016may.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu2016may.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu2016may.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Coding) - return convertCoding((org.hl7.fhir.dstu2016may.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Count) - return convertCount((org.hl7.fhir.dstu2016may.model.Count) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Distance) - return convertDistance((org.hl7.fhir.dstu2016may.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Duration) - return convertDuration((org.hl7.fhir.dstu2016may.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu2016may.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Money) - return convertMoney((org.hl7.fhir.dstu2016may.model.Money) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Period) - return convertPeriod((org.hl7.fhir.dstu2016may.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu2016may.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Range) - return convertRange((org.hl7.fhir.dstu2016may.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2016may.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Reference) - return convertReference((org.hl7.fhir.dstu2016may.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu2016may.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Signature) - return convertSignature((org.hl7.fhir.dstu2016may.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Address) - return convertAddress((org.hl7.fhir.dstu2016may.model.Address) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu2016may.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu2016may.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Meta) - return convertMeta((org.hl7.fhir.dstu2016may.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Timing) - return convertTiming((org.hl7.fhir.dstu2016may.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r4.model.BooleanType) - return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r4.model.CodeType) - return convertCode((org.hl7.fhir.r4.model.CodeType) src); - if (src instanceof org.hl7.fhir.r4.model.DateType) - return convertDate((org.hl7.fhir.r4.model.DateType) src); - if (src instanceof org.hl7.fhir.r4.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r4.model.DecimalType) - return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r4.model.IdType) - return convertId((org.hl7.fhir.r4.model.IdType) src); - if (src instanceof org.hl7.fhir.r4.model.InstantType) - return convertInstant((org.hl7.fhir.r4.model.InstantType) src); - if (src instanceof org.hl7.fhir.r4.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r4.model.OidType) - return convertOid((org.hl7.fhir.r4.model.OidType) src); - if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r4.model.StringType) - return convertString((org.hl7.fhir.r4.model.StringType) src); - if (src instanceof org.hl7.fhir.r4.model.TimeType) - return convertTime((org.hl7.fhir.r4.model.TimeType) src); - if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r4.model.IntegerType) - return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r4.model.UriType) - return convertUri((org.hl7.fhir.r4.model.UriType) src); - if (src instanceof org.hl7.fhir.r4.model.UuidType) - return convertUuid((org.hl7.fhir.r4.model.UuidType) src); - if (src instanceof org.hl7.fhir.r4.model.Extension) - return convertExtension((org.hl7.fhir.r4.model.Extension) src); - if (src instanceof org.hl7.fhir.r4.model.Narrative) - return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); - if (src instanceof org.hl7.fhir.r4.model.Age) - return convertAge((org.hl7.fhir.r4.model.Age) src); - if (src instanceof org.hl7.fhir.r4.model.Annotation) - return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); - if (src instanceof org.hl7.fhir.r4.model.Attachment) - return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); - if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r4.model.Coding) - return convertCoding((org.hl7.fhir.r4.model.Coding) src); - if (src instanceof org.hl7.fhir.r4.model.Count) - return convertCount((org.hl7.fhir.r4.model.Count) src); - if (src instanceof org.hl7.fhir.r4.model.Distance) - return convertDistance((org.hl7.fhir.r4.model.Distance) src); - if (src instanceof org.hl7.fhir.r4.model.Duration) - return convertDuration((org.hl7.fhir.r4.model.Duration) src); - if (src instanceof org.hl7.fhir.r4.model.Identifier) - return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); - if (src instanceof org.hl7.fhir.r4.model.Money) - return convertMoney((org.hl7.fhir.r4.model.Money) src); - if (src instanceof org.hl7.fhir.r4.model.Period) - return convertPeriod((org.hl7.fhir.r4.model.Period) src); - if (src instanceof org.hl7.fhir.r4.model.Quantity) - return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); - if (src instanceof org.hl7.fhir.r4.model.Range) - return convertRange((org.hl7.fhir.r4.model.Range) src); - if (src instanceof org.hl7.fhir.r4.model.Ratio) - return convertRatio((org.hl7.fhir.r4.model.Ratio) src); - if (src instanceof org.hl7.fhir.r4.model.Reference) - return convertReference((org.hl7.fhir.r4.model.Reference) src); - if (src instanceof org.hl7.fhir.r4.model.SampledData) - return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); - if (src instanceof org.hl7.fhir.r4.model.Signature) - return convertSignature((org.hl7.fhir.r4.model.Signature) src); - if (src instanceof org.hl7.fhir.r4.model.Address) - return convertAddress((org.hl7.fhir.r4.model.Address) src); - if (src instanceof org.hl7.fhir.r4.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r4.model.HumanName) - return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); - if (src instanceof org.hl7.fhir.r4.model.Meta) - return convertMeta((org.hl7.fhir.r4.model.Meta) src); - if (src instanceof org.hl7.fhir.r4.model.Timing) - return convertTiming((org.hl7.fhir.r4.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) if (s.equals(url)) - ok = true; - return ok; - } - - static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - public static org.hl7.fhir.r4.model.Binary convertBinary(org.hl7.fhir.dstu2016may.model.Binary src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Binary tgt = new org.hl7.fhir.r4.model.Binary(); - copyResource(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - tgt.setContent(src.getContent()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Binary convertBinary(org.hl7.fhir.r4.model.Binary src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Binary tgt = new org.hl7.fhir.dstu2016may.model.Binary(); - copyResource(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - tgt.setContent(src.getContent()); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); - break; - } - return tgt; - } - - static public boolean isJurisdiction(CodeableConcept t) { - return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); - } - - public static org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2016may.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext(); - result.setValue(convertCodeableConcept(t)); - return result; - } - - static public class SourceElementComponentWrapper { - - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - public String source; - - public String target; - - public org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent comp; - } - - static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { - CanonicalType dst = new CanonicalType(src.getReference()); - copyElement(src, dst); - return dst; - } - - static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { - Reference dst = new Reference(src.getValue()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertSearchParamType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityModeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventModeEnumFactory()); - VersionConvertor_14_40.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) - return Parameters14_40.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Bundle) - return Bundle14_40.convertBundle((org.hl7.fhir.dstu2016may.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeSystem) - return CodeSystem14_40.convertCodeSystem((org.hl7.fhir.dstu2016may.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CompartmentDefinition) - return CompartmentDefinition14_40.convertCompartmentDefinition((org.hl7.fhir.dstu2016may.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ConceptMap) - return ConceptMap14_40.convertConceptMap((org.hl7.fhir.dstu2016may.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Conformance) - return Conformance14_40.convertConformance((org.hl7.fhir.dstu2016may.model.Conformance) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DataElement) - return DataElement14_40.convertDataElement((org.hl7.fhir.dstu2016may.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ImplementationGuide) - return ImplementationGuide14_40.convertImplementationGuide((org.hl7.fhir.dstu2016may.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.NamingSystem) - return NamingSystem14_40.convertNamingSystem((org.hl7.fhir.dstu2016may.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OperationDefinition) - return OperationDefinition14_40.convertOperationDefinition((org.hl7.fhir.dstu2016may.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OperationOutcome) - return OperationOutcome14_40.convertOperationOutcome((org.hl7.fhir.dstu2016may.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Questionnaire) - return Questionnaire14_40.convertQuestionnaire((org.hl7.fhir.dstu2016may.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) - return QuestionnaireResponse14_40.convertQuestionnaireResponse((org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.SearchParameter) - return SearchParameter14_40.convertSearchParameter((org.hl7.fhir.dstu2016may.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StructureDefinition) - return StructureDefinition14_40.convertStructureDefinition((org.hl7.fhir.dstu2016may.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StructureMap) - return StructureMap14_40.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) - return ValueSet14_40.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r4.model.Parameters) - return Parameters14_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); - if (src instanceof org.hl7.fhir.r4.model.Bundle) - return Bundle14_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src); - if (src instanceof org.hl7.fhir.r4.model.CodeSystem) - return CodeSystem14_40.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) - return CompartmentDefinition14_40.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.ConceptMap) - return ConceptMap14_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) - return Conformance14_40.convertConformance((org.hl7.fhir.r4.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) - return ImplementationGuide14_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r4.model.NamingSystem) - return NamingSystem14_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) - return OperationDefinition14_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) - return OperationOutcome14_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r4.model.Questionnaire) - return Questionnaire14_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) - return QuestionnaireResponse14_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r4.model.SearchParameter) - return SearchParameter14_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) - return StructureDefinition14_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.StructureMap) - return StructureMap14_40.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); - if (src instanceof org.hl7.fhir.r4.model.ValueSet) - return ValueSet14_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "Bundle", "CodeSystem", "CompartmentDefinition", "ConceptMap", "CapabilityStatement", "ImplementationGuide", "NamingSystem", "OperationDefinition", "OperationOutcome", "Questionnaire", "QuestionnaireResponse", "SearchParameter", "StructureDefinition", "StructureMap", "ValueSet"); - } + isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); + } + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); + } + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + static public void convertTypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = null; + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : list) + if (t.getCode().equals(src.getCode())) tgt = t; + if (tgt == null) { + tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + } + if (tgt.hasTarget()) { + for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) { + if (src.getCode().equals("Reference")) tgt.addTargetProfile(u.getValue()); + else tgt.addProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) { + String s = ((org.hl7.fhir.dstu2016may.model.PrimitiveType) t.getValue()).getValue(); + tgt.addProfile(s); + } + } else { + for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2016may.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.r4.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue())); + } + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + } + + public static void convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + list.add(tgt); + if (src.hasTarget()) { + for (org.hl7.fhir.r4.model.UriType u : src.getTargetProfile()) { + tgt.addProfile(u.getValue()); + String baseName = u.getValue().toLowerCase(); + if (baseName.contains("reference") && !baseName.contains("documentreference")) + throw new Error("2016May Target profile contains the word 'reference':" + u); + } + for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { + if (src.getCode().equals("Reference")) { + org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION); + t.setValue(convertType(u)); + tgt.addExtension(t); + } else tgt.addProfile(u.getValue()); + } + } else { + for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { + tgt.addProfile(u.getValue()); + } + } + for (org.hl7.fhir.r4.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.dstu2016may.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue())); + } + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + } + + static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpression(convertToR4Expression(src.getExpression())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpression(convertTo2016MayExpression(src.getExpression())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static String convertToR4Expression(String oldExpression) { + String pass1 = oldExpression.replaceAll("\\$context", "%context").replaceAll("\\$resource", "%resource").replaceAll("code\\+profile", "code&profile").replaceAll("path\\+'\\.'", "path&'.'").replaceAll("fullUrl\\+resource", "fullUrl&resource"); + String pass2 = pass1; + if (pass1.endsWith(".distinct()")) pass2 = pass1.substring(0, pass2.length() - 11) + ".isDistinct()"; + String pass3 = pass2; + if (pass2.endsWith(".empty() or (type.count() = 1)")) + pass3 = pass2.substring(0, pass2.length() - 30) + ".empty() or (type.count() <= 1)"; + String pass4 = pass3; + if (pass3.equals("duration >= 0")) pass4 = "duration.exists() implies duration >= 0"; + else if (pass3.equals("period >= 0")) pass4 = "period.exists() implies period >= 0"; + else if (pass3.equals("fullUrl.empty() xor resource")) pass4 = "fullUrl.empty() xor resource.exists()"; + return pass4; + } + + public static String convertTo2016MayExpression(String newExpression) { + String pass1 = newExpression.replaceAll("%context", "\\$context").replaceAll("%resource", "\\$resource").replaceAll("code&profile", "code+profile").replaceAll("path&'\\.'", "path+'.'").replaceAll("fullUrl%resource", "fullUrl+resource"); + String pass2 = pass1; + if (pass1.endsWith(".isDistinct()")) pass2 = pass1.substring(0, pass1.length() - 13) + ".distinct()"; + String pass3 = pass2; + if (pass2.endsWith(".empty() or (type.count() <= 1)")) + pass3 = pass2.substring(0, pass2.length() - 31) + ".empty() or (type.count() = 1)"; + String pass4 = pass3; + if (pass3.equals("duration.exists() implies duration >= 0")) pass4 = "duration >= 0"; + else if (pass3.equals("period.exists() implies period >= 0")) pass4 = "period >= 0"; + else if (pass3.equals("fullUrl.empty() xor resource.exists()")) pass4 = "fullUrl.empty() xor resource"; + return pass4; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + org.hl7.fhir.r4.model.Type t = convertType(src.getValueSet()); + if (t instanceof org.hl7.fhir.r4.model.Reference) + tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); + else tgt.setValueSet(t.primitiveValue()); + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.Reference(src.getValueSet())); + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertBindingStrength(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.HumanName tgt = new org.hl7.fhir.dstu2016may.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.HumanName.NameUseEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu2016may.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) { + tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + } + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) { + tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + } + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2016may.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2016may.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2016may.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu2016may.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu2016may.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeType) + return convertCode((org.hl7.fhir.dstu2016may.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DateType) + return convertDate((org.hl7.fhir.dstu2016may.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu2016may.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu2016may.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.IdType) + return convertId((org.hl7.fhir.dstu2016may.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.InstantType) + return convertInstant((org.hl7.fhir.dstu2016may.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu2016may.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OidType) + return convertOid((org.hl7.fhir.dstu2016may.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu2016may.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StringType) + return convertString((org.hl7.fhir.dstu2016may.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.TimeType) + return convertTime((org.hl7.fhir.dstu2016may.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu2016may.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu2016may.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UriType) + return convertUri((org.hl7.fhir.dstu2016may.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UuidType) + return convertUuid((org.hl7.fhir.dstu2016may.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Extension) + return convertExtension((org.hl7.fhir.dstu2016may.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu2016may.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Age) + return convertAge((org.hl7.fhir.dstu2016may.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu2016may.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu2016may.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu2016may.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Coding) + return convertCoding((org.hl7.fhir.dstu2016may.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Count) + return convertCount((org.hl7.fhir.dstu2016may.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Distance) + return convertDistance((org.hl7.fhir.dstu2016may.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Duration) + return convertDuration((org.hl7.fhir.dstu2016may.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu2016may.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Money) + return convertMoney((org.hl7.fhir.dstu2016may.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Period) + return convertPeriod((org.hl7.fhir.dstu2016may.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu2016may.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Range) + return convertRange((org.hl7.fhir.dstu2016may.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Ratio) + return convertRatio((org.hl7.fhir.dstu2016may.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Reference) + return convertReference((org.hl7.fhir.dstu2016may.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu2016may.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Signature) + return convertSignature((org.hl7.fhir.dstu2016may.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Address) + return convertAddress((org.hl7.fhir.dstu2016may.model.Address) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu2016may.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu2016may.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Meta) + return convertMeta((org.hl7.fhir.dstu2016may.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Timing) + return convertTiming((org.hl7.fhir.dstu2016may.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r4.model.BooleanType) + return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r4.model.CodeType) return convertCode((org.hl7.fhir.r4.model.CodeType) src); + if (src instanceof org.hl7.fhir.r4.model.DateType) return convertDate((org.hl7.fhir.r4.model.DateType) src); + if (src instanceof org.hl7.fhir.r4.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r4.model.DecimalType) + return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r4.model.IdType) return convertId((org.hl7.fhir.r4.model.IdType) src); + if (src instanceof org.hl7.fhir.r4.model.InstantType) + return convertInstant((org.hl7.fhir.r4.model.InstantType) src); + if (src instanceof org.hl7.fhir.r4.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r4.model.OidType) return convertOid((org.hl7.fhir.r4.model.OidType) src); + if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r4.model.StringType) + return convertString((org.hl7.fhir.r4.model.StringType) src); + if (src instanceof org.hl7.fhir.r4.model.TimeType) return convertTime((org.hl7.fhir.r4.model.TimeType) src); + if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r4.model.IntegerType) + return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r4.model.UriType) return convertUri((org.hl7.fhir.r4.model.UriType) src); + if (src instanceof org.hl7.fhir.r4.model.UuidType) return convertUuid((org.hl7.fhir.r4.model.UuidType) src); + if (src instanceof org.hl7.fhir.r4.model.Extension) + return convertExtension((org.hl7.fhir.r4.model.Extension) src); + if (src instanceof org.hl7.fhir.r4.model.Narrative) + return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); + if (src instanceof org.hl7.fhir.r4.model.Age) return convertAge((org.hl7.fhir.r4.model.Age) src); + if (src instanceof org.hl7.fhir.r4.model.Annotation) + return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); + if (src instanceof org.hl7.fhir.r4.model.Attachment) + return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); + if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r4.model.Coding) return convertCoding((org.hl7.fhir.r4.model.Coding) src); + if (src instanceof org.hl7.fhir.r4.model.Count) return convertCount((org.hl7.fhir.r4.model.Count) src); + if (src instanceof org.hl7.fhir.r4.model.Distance) return convertDistance((org.hl7.fhir.r4.model.Distance) src); + if (src instanceof org.hl7.fhir.r4.model.Duration) return convertDuration((org.hl7.fhir.r4.model.Duration) src); + if (src instanceof org.hl7.fhir.r4.model.Identifier) + return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); + if (src instanceof org.hl7.fhir.r4.model.Money) return convertMoney((org.hl7.fhir.r4.model.Money) src); + if (src instanceof org.hl7.fhir.r4.model.Period) return convertPeriod((org.hl7.fhir.r4.model.Period) src); + if (src instanceof org.hl7.fhir.r4.model.Quantity) return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); + if (src instanceof org.hl7.fhir.r4.model.Range) return convertRange((org.hl7.fhir.r4.model.Range) src); + if (src instanceof org.hl7.fhir.r4.model.Ratio) return convertRatio((org.hl7.fhir.r4.model.Ratio) src); + if (src instanceof org.hl7.fhir.r4.model.Reference) + return convertReference((org.hl7.fhir.r4.model.Reference) src); + if (src instanceof org.hl7.fhir.r4.model.SampledData) + return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); + if (src instanceof org.hl7.fhir.r4.model.Signature) + return convertSignature((org.hl7.fhir.r4.model.Signature) src); + if (src instanceof org.hl7.fhir.r4.model.Address) return convertAddress((org.hl7.fhir.r4.model.Address) src); + if (src instanceof org.hl7.fhir.r4.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r4.model.HumanName) + return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); + if (src instanceof org.hl7.fhir.r4.model.Meta) return convertMeta((org.hl7.fhir.r4.model.Meta) src); + if (src instanceof org.hl7.fhir.r4.model.Timing) return convertTiming((org.hl7.fhir.r4.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; + } + + static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + public static org.hl7.fhir.r4.model.Binary convertBinary(org.hl7.fhir.dstu2016may.model.Binary src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Binary tgt = new org.hl7.fhir.r4.model.Binary(); + copyResource(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + tgt.setContent(src.getContent()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Binary convertBinary(org.hl7.fhir.r4.model.Binary src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Binary tgt = new org.hl7.fhir.dstu2016may.model.Binary(); + copyResource(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + tgt.setContent(src.getContent()); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); + break; + } + } + return tgt; + } + + static public boolean isJurisdiction(CodeableConcept t) { + return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); + } + + public static org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2016may.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext(); + result.setValue(convertCodeableConcept(t)); + return result; + } + + static public class SourceElementComponentWrapper { + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; + } + + public String source; + public String target; + public org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent comp; + } + + static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { + CanonicalType dst = new CanonicalType(src.getReference()); + copyElement(src, dst); + return dst; + } + + static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { + Reference dst = new Reference(src.getValue()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertSearchParamType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityModeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.CapabilityStatement.EventCapabilityMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventModeEnumFactory()); + VersionConvertor_14_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) + return Parameters14_40.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Bundle) + return Bundle14_40.convertBundle((org.hl7.fhir.dstu2016may.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeSystem) + return CodeSystem14_40.convertCodeSystem((org.hl7.fhir.dstu2016may.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CompartmentDefinition) + return CompartmentDefinition14_40.convertCompartmentDefinition((org.hl7.fhir.dstu2016may.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ConceptMap) + return ConceptMap14_40.convertConceptMap((org.hl7.fhir.dstu2016may.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Conformance) + return Conformance14_40.convertConformance((org.hl7.fhir.dstu2016may.model.Conformance) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DataElement) + return DataElement14_40.convertDataElement((org.hl7.fhir.dstu2016may.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ImplementationGuide) + return ImplementationGuide14_40.convertImplementationGuide((org.hl7.fhir.dstu2016may.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.NamingSystem) + return NamingSystem14_40.convertNamingSystem((org.hl7.fhir.dstu2016may.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OperationDefinition) + return OperationDefinition14_40.convertOperationDefinition((org.hl7.fhir.dstu2016may.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OperationOutcome) + return OperationOutcome14_40.convertOperationOutcome((org.hl7.fhir.dstu2016may.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Questionnaire) + return Questionnaire14_40.convertQuestionnaire((org.hl7.fhir.dstu2016may.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) + return QuestionnaireResponse14_40.convertQuestionnaireResponse((org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.SearchParameter) + return SearchParameter14_40.convertSearchParameter((org.hl7.fhir.dstu2016may.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StructureDefinition) + return StructureDefinition14_40.convertStructureDefinition((org.hl7.fhir.dstu2016may.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StructureMap) + return StructureMap14_40.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) + return ValueSet14_40.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r4.model.Parameters) + return Parameters14_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); + if (src instanceof org.hl7.fhir.r4.model.Bundle) + return Bundle14_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src); + if (src instanceof org.hl7.fhir.r4.model.CodeSystem) + return CodeSystem14_40.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) + return CompartmentDefinition14_40.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.ConceptMap) + return ConceptMap14_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) + return Conformance14_40.convertConformance((org.hl7.fhir.r4.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) + return ImplementationGuide14_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r4.model.NamingSystem) + return NamingSystem14_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) + return OperationDefinition14_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) + return OperationOutcome14_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r4.model.Questionnaire) + return Questionnaire14_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) + return QuestionnaireResponse14_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r4.model.SearchParameter) + return SearchParameter14_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) + return StructureDefinition14_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.StructureMap) + return StructureMap14_40.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); + if (src instanceof org.hl7.fhir.r4.model.ValueSet) + return ValueSet14_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "Bundle", "CodeSystem", "CompartmentDefinition", "ConceptMap", "CapabilityStatement", "ImplementationGuide", "NamingSystem", "OperationDefinition", "OperationOutcome", "Questionnaire", "QuestionnaireResponse", "SearchParameter", "StructureDefinition", "StructureMap", "ValueSet"); + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java index d0ad44110..19ce5f71a 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_50.java @@ -1,5 +1,15 @@ package org.hl7.fhir.convertors; +import org.hl7.fhir.convertors.conv14_50.*; +import org.hl7.fhir.dstu2016may.model.CodeableConcept; +import org.hl7.fhir.dstu2016may.model.Reference; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.conformance.ProfileUtilities; +import org.hl7.fhir.r5.model.CanonicalType; +import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; +import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; +import org.hl7.fhir.utilities.Utilities; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -31,3092 +41,2706 @@ import java.util.stream.Collectors; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -import org.hl7.fhir.convertors.conv14_50.Bundle14_50; -import org.hl7.fhir.convertors.conv14_50.CodeSystem14_50; -import org.hl7.fhir.convertors.conv14_50.CompartmentDefinition14_50; -import org.hl7.fhir.convertors.conv14_50.ConceptMap14_50; -import org.hl7.fhir.convertors.conv14_50.Conformance14_50; -import org.hl7.fhir.convertors.conv14_50.DataElement14_50; -import org.hl7.fhir.convertors.conv14_50.ImplementationGuide14_50; -import org.hl7.fhir.convertors.conv14_50.NamingSystem14_50; -import org.hl7.fhir.convertors.conv14_50.OperationDefinition14_50; -import org.hl7.fhir.convertors.conv14_50.OperationOutcome14_50; -import org.hl7.fhir.convertors.conv14_50.Parameters14_50; -import org.hl7.fhir.convertors.conv14_50.Questionnaire14_50; -import org.hl7.fhir.convertors.conv14_50.QuestionnaireResponse14_50; -import org.hl7.fhir.convertors.conv14_50.SearchParameter14_50; -import org.hl7.fhir.convertors.conv14_50.StructureDefinition14_50; -import org.hl7.fhir.convertors.conv14_50.StructureMap14_50; -import org.hl7.fhir.convertors.conv14_50.ValueSet14_50; -import org.hl7.fhir.dstu2016may.model.CodeableConcept; -import org.hl7.fhir.dstu2016may.model.Reference; -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r5.conformance.ProfileUtilities; -import org.hl7.fhir.r5.model.CanonicalType; -import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent; -import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent; -import org.hl7.fhir.r5.model.Enumeration; -import org.hl7.fhir.r5.model.Timing.EventTiming; -import org.hl7.fhir.utilities.Utilities; public class VersionConvertor_14_50 { - - static public List CANONICAL_URLS = new ArrayList(); - - static { - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); - } - - static public boolean mappedExtension(String url) { - if (url.equals(VersionConvertorConstants.PROFILE_EXTENSION) || url.equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || url.equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION) || url.equals(VersionConvertorConstants.IG_CONFORMANCE_MESSAGE_EVENT)) - return true; - return false; - } - - static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { - if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && !mappedExtension(e.getUrl().toString())) - tgt.addExtension(convertExtension(e)); - } - } - - static public void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { - if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - static public void copyBackboneElement(org.hl7.fhir.dstu2016may.model.BackboneElement src, org.hl7.fhir.r5.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - static public void copyBackboneElement(org.hl7.fhir.r5.model.BackboneElement src, org.hl7.fhir.dstu2016may.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = new org.hl7.fhir.r5.model.Base64BinaryType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = new org.hl7.fhir.r5.model.CodeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = new org.hl7.fhir.r5.model.DateType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = new org.hl7.fhir.r5.model.DecimalType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = new org.hl7.fhir.r5.model.IdType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = new org.hl7.fhir.r5.model.InstantType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = new org.hl7.fhir.r5.model.IntegerType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = new org.hl7.fhir.r5.model.MarkdownType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = new org.hl7.fhir.r5.model.OidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = new org.hl7.fhir.r5.model.PositiveIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = new org.hl7.fhir.r5.model.StringType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = new org.hl7.fhir.r5.model.TimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = new org.hl7.fhir.r5.model.UnsignedIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = new org.hl7.fhir.r5.model.UuidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); - if (src.hasValue()) - tgt.setValue(src.getValue()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2016may.model.Reference) - tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); - copyElement(src, tgt); - if (src.hasUrlElement()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) - tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.dstu2016may.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Age tgt = new org.hl7.fhir.dstu2016may.model.Age(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.dstu2016may.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Annotation tgt = new org.hl7.fhir.dstu2016may.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu2016may.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSize(Long.valueOf(src.getSize())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Attachment tgt = new org.hl7.fhir.dstu2016may.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSize(Math.toIntExact(src.getSize())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.CodeableConcept tgt = new org.hl7.fhir.dstu2016may.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu2016may.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.dstu2016may.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Count tgt = new org.hl7.fhir.dstu2016may.model.Count(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.dstu2016may.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Distance tgt = new org.hl7.fhir.dstu2016may.model.Distance(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.dstu2016may.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Duration tgt = new org.hl7.fhir.dstu2016may.model.Duration(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.dstu2016may.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCode()) - tgt.setCurrencyElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Money tgt = new org.hl7.fhir.dstu2016may.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrency()) - tgt.setCodeElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu2016may.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Identifier tgt = new org.hl7.fhir.dstu2016may.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.dstu2016may.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Period tgt = new org.hl7.fhir.dstu2016may.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.dstu2016may.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Range tgt = new org.hl7.fhir.dstu2016may.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.dstu2016may.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Ratio tgt = new org.hl7.fhir.dstu2016may.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.dstu2016may.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Reference tgt = new org.hl7.fhir.dstu2016may.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.dstu2016may.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.SampledData tgt = new org.hl7.fhir.dstu2016may.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriodElement()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensionsElement()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasDataElement()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWhoUriType()) - tgt.setWho(new org.hl7.fhir.r5.model.Reference(src.getWhoUriType().getValue())); - else - tgt.setWho(convertReference(src.getWhoReference())); - if (src.hasContentType()) - tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); - if (src.hasBlob()) - tgt.setDataElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhenElement()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasSigFormat()) - tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); - if (src.hasData()) - tgt.setBlobElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.dstu2016may.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Address tgt = new org.hl7.fhir.dstu2016may.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressTypeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.URL); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition src, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_14_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasName()) - tgt.setSliceNameElement(convertString(src.getNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComments()) - tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - // work around for problem in R2B definitions: - if (!src.hasContentReference()) { - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (tgt.getIsModifier()) { - String reason = org.hl7.fhir.dstu2016may.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); - if (Utilities.noString(reason)) - reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; - tgt.setIsModifierReason(reason); + static public List CANONICAL_URLS = new ArrayList(); + + static { + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + } + + static public boolean mappedExtension(String url) { + if (url.equals(VersionConvertorConstants.PROFILE_EXTENSION) || url.equals(VersionConvertorConstants.IG_DEPENDSON_PACKAGE_EXTENSION) || url.equals(VersionConvertorConstants.IG_DEPENDSON_VERSION_EXTENSION) || url.equals(VersionConvertorConstants.IG_CONFORMANCE_MESSAGE_EVENT)) + return true; + return false; + } + + static public void copyElement(org.hl7.fhir.dstu2016may.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... exemptExtensions) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.dstu2016may.model.Extension e : src.getExtension()) { + if (!Utilities.existsInList(e.getUrl(), exemptExtensions) && !mappedExtension(e.getUrl().toString())) + tgt.addExtension(convertExtension(e)); + } + } + + static public void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu2016may.model.Element tgt, String... exemptExtensions) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { + if (!Utilities.existsInList(e.getUrl(), exemptExtensions)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + static public void copyBackboneElement(org.hl7.fhir.dstu2016may.model.BackboneElement src, org.hl7.fhir.r5.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + static public void copyBackboneElement(org.hl7.fhir.r5.model.BackboneElement src, org.hl7.fhir.dstu2016may.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r5.model.Base64BinaryType tgt = new org.hl7.fhir.r5.model.Base64BinaryType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu2016may.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.BooleanType tgt = new org.hl7.fhir.dstu2016may.model.BooleanType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu2016may.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.CodeType tgt = new org.hl7.fhir.r5.model.CodeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.CodeType tgt = new org.hl7.fhir.dstu2016may.model.CodeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu2016may.model.DateType src) throws FHIRException { + org.hl7.fhir.r5.model.DateType tgt = new org.hl7.fhir.r5.model.DateType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DateType tgt = new org.hl7.fhir.dstu2016may.model.DateType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu2016may.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r5.model.DateTimeType tgt = new org.hl7.fhir.r5.model.DateTimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DateTimeType tgt = new org.hl7.fhir.dstu2016may.model.DateTimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r5.model.DecimalType tgt = new org.hl7.fhir.r5.model.DecimalType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { + org.hl7.fhir.r5.model.IdType tgt = new org.hl7.fhir.r5.model.IdType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.IdType tgt = new org.hl7.fhir.dstu2016may.model.IdType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu2016may.model.InstantType src) throws FHIRException { + org.hl7.fhir.r5.model.InstantType tgt = new org.hl7.fhir.r5.model.InstantType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.InstantType tgt = new org.hl7.fhir.dstu2016may.model.InstantType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu2016may.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r5.model.IntegerType tgt = new org.hl7.fhir.r5.model.IntegerType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.IntegerType tgt = new org.hl7.fhir.dstu2016may.model.IntegerType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu2016may.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = new org.hl7.fhir.r5.model.MarkdownType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.MarkdownType tgt = new org.hl7.fhir.dstu2016may.model.MarkdownType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu2016may.model.OidType src) throws FHIRException { + org.hl7.fhir.r5.model.OidType tgt = new org.hl7.fhir.r5.model.OidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.OidType tgt = new org.hl7.fhir.dstu2016may.model.OidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu2016may.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r5.model.PositiveIntType tgt = new org.hl7.fhir.r5.model.PositiveIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.PositiveIntType tgt = new org.hl7.fhir.dstu2016may.model.PositiveIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu2016may.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.StringType tgt = new org.hl7.fhir.r5.model.StringType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.StringType tgt = new org.hl7.fhir.dstu2016may.model.StringType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu2016may.model.TimeType src) throws FHIRException { + org.hl7.fhir.r5.model.TimeType tgt = new org.hl7.fhir.r5.model.TimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.TimeType tgt = new org.hl7.fhir.dstu2016may.model.TimeType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu2016may.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r5.model.UnsignedIntType tgt = new org.hl7.fhir.r5.model.UnsignedIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UnsignedIntType tgt = new org.hl7.fhir.dstu2016may.model.UnsignedIntType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu2016may.model.UriType src) throws FHIRException { + org.hl7.fhir.r5.model.UriType tgt = new org.hl7.fhir.r5.model.UriType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UriType tgt = new org.hl7.fhir.dstu2016may.model.UriType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu2016may.model.UuidType src) throws FHIRException { + org.hl7.fhir.r5.model.UuidType tgt = new org.hl7.fhir.r5.model.UuidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu2016may.model.UuidType tgt = new org.hl7.fhir.dstu2016may.model.UuidType(); + if (src.hasValue()) tgt.setValue(src.getValue()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu2016may.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu2016may.model.Reference) + tgt.setValue(convertReferenceToCanonical((Reference) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); + copyElement(src, tgt); + if (src.hasUrlElement()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) + tgt.setValue(convertCanonicalToReference((CanonicalType) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.dstu2016may.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Age tgt = new org.hl7.fhir.dstu2016may.model.Age(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.dstu2016may.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Annotation tgt = new org.hl7.fhir.dstu2016may.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu2016may.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSize(Long.valueOf(src.getSize())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Attachment tgt = new org.hl7.fhir.dstu2016may.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSize(Math.toIntExact(src.getSize())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.CodeableConcept tgt = new org.hl7.fhir.dstu2016may.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu2016may.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Coding tgt = new org.hl7.fhir.dstu2016may.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.dstu2016may.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Count tgt = new org.hl7.fhir.dstu2016may.model.Count(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.dstu2016may.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Distance tgt = new org.hl7.fhir.dstu2016may.model.Distance(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.dstu2016may.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Duration tgt = new org.hl7.fhir.dstu2016may.model.Duration(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.dstu2016may.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCode()) tgt.setCurrencyElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Money tgt = new org.hl7.fhir.dstu2016may.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrency()) tgt.setCodeElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu2016may.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Identifier tgt = new org.hl7.fhir.dstu2016may.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.dstu2016may.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Period tgt = new org.hl7.fhir.dstu2016may.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.dstu2016may.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Range tgt = new org.hl7.fhir.dstu2016may.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.dstu2016may.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Ratio tgt = new org.hl7.fhir.dstu2016may.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.dstu2016may.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Reference tgt = new org.hl7.fhir.dstu2016may.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.dstu2016may.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.SampledData tgt = new org.hl7.fhir.dstu2016may.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensionsElement()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasDataElement()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.dstu2016may.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r5.model.Reference(src.getWhoUriType().getValue())); + else tgt.setWho(convertReference(src.getWhoReference())); + if (src.hasContentType()) tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); + if (src.hasBlob()) tgt.setDataElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Signature tgt = new org.hl7.fhir.dstu2016may.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhenElement()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasSigFormat()) tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); + if (src.hasData()) tgt.setBlobElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.dstu2016may.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Address tgt = new org.hl7.fhir.dstu2016may.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Address.AddressTypeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.URL); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_14_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasName()) tgt.setSliceNameElement(convertString(src.getNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos)); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComments()) tgt.setCommentElement(convertMarkdown(src.getCommentsElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) + tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + // work around for problem in R2B definitions: + if (!src.hasContentReference()) { + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.addExample().setLabel("General").setValue(convertType(src.getExample())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (tgt.getIsModifier()) { + String reason = org.hl7.fhir.dstu2016may.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); + if (Utilities.noString(reason)) reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; + tgt.setIsModifierReason(reason); + } + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + } + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_14_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMin(src.getMin()); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + if (src.hasExample()) tgt.setExample(convertType(src.getExample().get(0).getValue())); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) + org.hl7.fhir.dstu2016may.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + org.hl7.fhir.dstu2016may.model.ElementDefinition slicingElement = context.get(pos); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) { + boolean isExists = false; + if (!t.asStringValue().contains("@")) { + int slices = 0; + boolean existsSlicePresent = false; + boolean notExistsSlicePresent = false; + String existsPath = slicingElement.getPath() + "." + t.asStringValue(); + for (int i = pos + 1; i < context.size(); i++) { + org.hl7.fhir.dstu2016may.model.ElementDefinition e = context.get(i); + if (e.getPath().equals(slicingElement.getPath())) slices++; + else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) break; + else if (e.getPath().equals(existsPath)) { + if (e.hasMin() && e.getMin() > 0 && !e.hasFixed()) existsSlicePresent = true; + else if (e.hasMax() && e.getMax().equals("0")) notExistsSlicePresent = true; } - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); } - return tgt; + isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); + } + tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); } + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } - public static org.hl7.fhir.dstu2016may.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_14_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentsElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMin(src.getMin()); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - if (src.hasExample()) - tgt.setExample(convertType(src.getExample().get(0).getValue())); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) - org.hl7.fhir.dstu2016may.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + break; + } } + return tgt; + } - static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); - break; + static public org.hl7.fhir.dstu2016may.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPathElement()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setMin(src.getMin()); + if (src.hasMaxElement()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + static public void convertTypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = null; + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : list) + if (t.getCode().equals(src.getCode())) tgt = t; + if (tgt == null) { + tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + } + if (tgt.hasTarget()) { + for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) { + if (src.getCode().equals("Reference")) tgt.addTargetProfile(u.getValue()); + else tgt.addProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) { + String s = ((org.hl7.fhir.dstu2016may.model.PrimitiveType) t.getValue()).getValue(); + tgt.addProfile(s); + } + } else { + for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); + } + for (org.hl7.fhir.dstu2016may.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.r5.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue())); + } + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + } + + public static void convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + list.add(tgt); + if (src.hasTarget()) { + for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { + org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION); + t.setValue(convertType(u)); + tgt.addExtension(t); + } + for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) { + if (!u.equals(src.getTargetProfile().get(0))) { + tgt = tgt.copy(); + tgt.getProfile().clear(); + list.add(tgt); } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent src, List context, int pos) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - org.hl7.fhir.dstu2016may.model.ElementDefinition slicingElement = context.get(pos); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getDiscriminator()) { - boolean isExists = false; - if (!t.asStringValue().contains("@")) { - int slices = 0; - boolean existsSlicePresent = false; - boolean notExistsSlicePresent = false; - String existsPath = slicingElement.getPath() + "." + t.asStringValue(); - for (int i = pos + 1; i < context.size(); i++) { - org.hl7.fhir.dstu2016may.model.ElementDefinition e = context.get(i); - if (e.getPath().equals(slicingElement.getPath())) - slices++; - else if (!e.getPath().startsWith(slicingElement.getPath() + ".")) - break; - else if (e.getPath().equals(existsPath)) { - if (e.hasMin() && e.getMin() > 0 && !e.hasFixed()) - existsSlicePresent = true; - else if (e.hasMax() && e.getMax().equals("0")) - notExistsSlicePresent = true; - } - } - isExists = (slices == 2 && existsSlicePresent && notExistsSlicePresent) || (slices == 1 && existsSlicePresent != notExistsSlicePresent); - } - tgt.addDiscriminator(ProfileUtilities.interpretR2Discriminator(t.getValue(), isExists)); - } - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(ProfileUtilities.buildR2Discriminator(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPathElement()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setMin(src.getMin()); - if (src.hasMaxElement()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - static public void convertTypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = null; - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : list) if (t.getCode().equals(src.getCode())) - tgt = t; - if (tgt == null) { - tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - } - if (tgt.hasTarget()) { - for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) { - if (src.getCode().equals("Reference")) - tgt.addTargetProfile(u.getValue()); - else - tgt.addProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtensionsByUrl(VersionConvertorConstants.PROFILE_EXTENSION)) { - String s = ((org.hl7.fhir.dstu2016may.model.PrimitiveType) t.getValue()).getValue(); - tgt.addProfile(s); - } - } else { - for (org.hl7.fhir.dstu2016may.model.UriType u : src.getProfile()) tgt.addProfile(u.getValue()); - } - for (org.hl7.fhir.dstu2016may.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.r5.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregation(a.getValue())); - } - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - } - - public static void convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - list.add(tgt); - if (src.hasTarget()) { - for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { - org.hl7.fhir.dstu2016may.model.Extension t = new org.hl7.fhir.dstu2016may.model.Extension(VersionConvertorConstants.PROFILE_EXTENSION); - t.setValue(convertType(u)); - tgt.addExtension(t); - } - for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) { - if (!u.equals(src.getTargetProfile().get(0))) { - tgt = tgt.copy(); - tgt.getProfile().clear(); - list.add(tgt); - } - tgt.addProfile(u.getValue()); - } - } else { - for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { - tgt.addProfile(u.getValue()); - } - } - for (org.hl7.fhir.r5.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.dstu2016may.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregationElement().setValue(a.getValue())); - } - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - } - - static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpression(convertToR4Expression(src.getExpression())); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKeyElement()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHumanElement()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpression(convertTo2016MayExpression(src.getExpression())); - if (src.hasXpathElement()) - tgt.setXpathElement(convertString(src.getXpathElement())); - return tgt; - } - - public static String convertToR4Expression(String oldExpression) { - String pass1 = oldExpression.replaceAll("\\$context", "%context").replaceAll("\\$resource", "%resource").replaceAll("code\\+profile", "code&profile").replaceAll("path\\+'\\.'", "path&'.'").replaceAll("fullUrl\\+resource", "fullUrl&resource"); - String pass2 = pass1; - if (pass1.endsWith(".distinct()")) - pass2 = pass1.substring(0, pass2.length() - 11) + ".isDistinct()"; - String pass3 = pass2; - if (pass2.endsWith(".empty() or (type.count() = 1)")) - pass3 = pass2.substring(0, pass2.length() - 30) + ".empty() or (type.count() <= 1)"; - String pass4 = pass3; - if (pass3.equals("duration >= 0")) - pass4 = "duration.exists() implies duration >= 0"; - else if (pass3.equals("period >= 0")) - pass4 = "period.exists() implies period >= 0"; - else if (pass3.equals("fullUrl.empty() xor resource")) - pass4 = "fullUrl.empty() xor resource.exists()"; - return pass4; - } - - public static String convertTo2016MayExpression(String newExpression) { - String pass1 = newExpression.replaceAll("%context", "\\$context").replaceAll("%resource", "\\$resource").replaceAll("code&profile", "code+profile").replaceAll("path&'\\.'", "path+'.'").replaceAll("fullUrl%resource", "fullUrl+resource"); - String pass2 = pass1; - if (pass1.endsWith(".isDistinct()")) - pass2 = pass1.substring(0, pass1.length() - 13) + ".distinct()"; - String pass3 = pass2; - if (pass2.endsWith(".empty() or (type.count() <= 1)")) - pass3 = pass2.substring(0, pass2.length() - 31) + ".empty() or (type.count() = 1)"; - String pass4 = pass3; - if (pass3.equals("duration.exists() implies duration >= 0")) - pass4 = "duration >= 0"; - else if (pass3.equals("period.exists() implies period >= 0")) - pass4 = "period >= 0"; - else if (pass3.equals("fullUrl.empty() xor resource.exists()")) - pass4 = "fullUrl.empty() xor resource"; - return pass4; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - org.hl7.fhir.r5.model.DataType t = convertType(src.getValueSet()); - if (t instanceof org.hl7.fhir.r5.model.Reference) - tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference()); - else - tgt.setValueSet(t.primitiveValue()); - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.Reference(src.getValueSet())); - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertBindingStrength(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentityElement()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMapElement()) - tgt.setMapElement(convertString(src.getMapElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.HumanName tgt = new org.hl7.fhir.dstu2016may.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.addFamily(src.getFamily()); - for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.HumanName.NameUseEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.dstu2016may.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu2016may.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case HS: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2016may.model.SimpleQuantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.SimpleQuantity tgt = new org.hl7.fhir.r5.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2016may.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2016may.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu2016may.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu2016may.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeType) - return convertCode((org.hl7.fhir.dstu2016may.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DateType) - return convertDate((org.hl7.fhir.dstu2016may.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu2016may.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu2016may.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.IdType) - return convertId((org.hl7.fhir.dstu2016may.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.InstantType) - return convertInstant((org.hl7.fhir.dstu2016may.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu2016may.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OidType) - return convertOid((org.hl7.fhir.dstu2016may.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu2016may.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StringType) - return convertString((org.hl7.fhir.dstu2016may.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.TimeType) - return convertTime((org.hl7.fhir.dstu2016may.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu2016may.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu2016may.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UriType) - return convertUri((org.hl7.fhir.dstu2016may.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.UuidType) - return convertUuid((org.hl7.fhir.dstu2016may.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Extension) - return convertExtension((org.hl7.fhir.dstu2016may.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu2016may.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Age) - return convertAge((org.hl7.fhir.dstu2016may.model.Age) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu2016may.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu2016may.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu2016may.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Coding) - return convertCoding((org.hl7.fhir.dstu2016may.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Count) - return convertCount((org.hl7.fhir.dstu2016may.model.Count) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Distance) - return convertDistance((org.hl7.fhir.dstu2016may.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Duration) - return convertDuration((org.hl7.fhir.dstu2016may.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu2016may.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Money) - return convertMoney((org.hl7.fhir.dstu2016may.model.Money) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Period) - return convertPeriod((org.hl7.fhir.dstu2016may.model.Period) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu2016may.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Range) - return convertRange((org.hl7.fhir.dstu2016may.model.Range) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Ratio) - return convertRatio((org.hl7.fhir.dstu2016may.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Reference) - return convertReference((org.hl7.fhir.dstu2016may.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu2016may.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Signature) - return convertSignature((org.hl7.fhir.dstu2016may.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Address) - return convertAddress((org.hl7.fhir.dstu2016may.model.Address) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu2016may.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu2016may.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Meta) - return convertMeta((org.hl7.fhir.dstu2016may.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Timing) - return convertTiming((org.hl7.fhir.dstu2016may.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r5.model.BooleanType) - return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r5.model.CodeType) - return convertCode((org.hl7.fhir.r5.model.CodeType) src); - if (src instanceof org.hl7.fhir.r5.model.DateType) - return convertDate((org.hl7.fhir.r5.model.DateType) src); - if (src instanceof org.hl7.fhir.r5.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r5.model.DecimalType) - return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r5.model.IdType) - return convertId((org.hl7.fhir.r5.model.IdType) src); - if (src instanceof org.hl7.fhir.r5.model.InstantType) - return convertInstant((org.hl7.fhir.r5.model.InstantType) src); - if (src instanceof org.hl7.fhir.r5.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r5.model.OidType) - return convertOid((org.hl7.fhir.r5.model.OidType) src); - if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r5.model.StringType) - return convertString((org.hl7.fhir.r5.model.StringType) src); - if (src instanceof org.hl7.fhir.r5.model.TimeType) - return convertTime((org.hl7.fhir.r5.model.TimeType) src); - if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r5.model.IntegerType) - return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r5.model.UriType) - return convertUri((org.hl7.fhir.r5.model.UriType) src); - if (src instanceof org.hl7.fhir.r5.model.UuidType) - return convertUuid((org.hl7.fhir.r5.model.UuidType) src); - if (src instanceof org.hl7.fhir.r5.model.Extension) - return convertExtension((org.hl7.fhir.r5.model.Extension) src); - if (src instanceof org.hl7.fhir.r5.model.Narrative) - return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); - if (src instanceof org.hl7.fhir.r5.model.Age) - return convertAge((org.hl7.fhir.r5.model.Age) src); - if (src instanceof org.hl7.fhir.r5.model.Annotation) - return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); - if (src instanceof org.hl7.fhir.r5.model.Attachment) - return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); - if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r5.model.Coding) - return convertCoding((org.hl7.fhir.r5.model.Coding) src); - if (src instanceof org.hl7.fhir.r5.model.Count) - return convertCount((org.hl7.fhir.r5.model.Count) src); - if (src instanceof org.hl7.fhir.r5.model.Distance) - return convertDistance((org.hl7.fhir.r5.model.Distance) src); - if (src instanceof org.hl7.fhir.r5.model.Duration) - return convertDuration((org.hl7.fhir.r5.model.Duration) src); - if (src instanceof org.hl7.fhir.r5.model.Identifier) - return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); - if (src instanceof org.hl7.fhir.r5.model.Money) - return convertMoney((org.hl7.fhir.r5.model.Money) src); - if (src instanceof org.hl7.fhir.r5.model.Period) - return convertPeriod((org.hl7.fhir.r5.model.Period) src); - if (src instanceof org.hl7.fhir.r5.model.Quantity) - return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); - if (src instanceof org.hl7.fhir.r5.model.Range) - return convertRange((org.hl7.fhir.r5.model.Range) src); - if (src instanceof org.hl7.fhir.r5.model.Ratio) - return convertRatio((org.hl7.fhir.r5.model.Ratio) src); - if (src instanceof org.hl7.fhir.r5.model.Reference) - return convertReference((org.hl7.fhir.r5.model.Reference) src); - if (src instanceof org.hl7.fhir.r5.model.SampledData) - return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); - if (src instanceof org.hl7.fhir.r5.model.Signature) - return convertSignature((org.hl7.fhir.r5.model.Signature) src); - if (src instanceof org.hl7.fhir.r5.model.Address) - return convertAddress((org.hl7.fhir.r5.model.Address) src); - if (src instanceof org.hl7.fhir.r5.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r5.model.HumanName) - return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); - if (src instanceof org.hl7.fhir.r5.model.Meta) - return convertMeta((org.hl7.fhir.r5.model.Meta) src); - if (src instanceof org.hl7.fhir.r5.model.Timing) - return convertTiming((org.hl7.fhir.r5.model.Timing) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) if (s.equals(url)) - ok = true; - return ok; - } - - static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t)); - } - - static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - public static org.hl7.fhir.r5.model.Binary convertBinary(org.hl7.fhir.dstu2016may.model.Binary src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Binary tgt = new org.hl7.fhir.r5.model.Binary(); - copyResource(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasContent()) - tgt.setContent(src.getContent()); - return tgt; - } - - public static org.hl7.fhir.dstu2016may.model.Binary convertBinary(org.hl7.fhir.r5.model.Binary src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Binary tgt = new org.hl7.fhir.dstu2016may.model.Binary(); - copyResource(src, tgt); - if (src.hasContentTypeElement()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - tgt.setContentElement(convertBase64Binary(src.getContentElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.RETIRED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); - break; - } - return tgt; - } - - static public boolean isJurisdiction(CodeableConcept t) { - return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); - } - - public static org.hl7.fhir.r5.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2016may.model.CodeableConcept t) throws FHIRException { - org.hl7.fhir.r5.model.UsageContext result = new org.hl7.fhir.r5.model.UsageContext(); - result.setValue(convertCodeableConcept(t)); - return result; - } - - static public class SourceElementComponentWrapper { - - public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { - super(); - this.source = source; - this.target = target; - this.comp = comp; - } - - public String source; - - public String target; - - public org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent comp; - } - - static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { - CanonicalType dst = new CanonicalType(src.getReference()); - copyElement(src, dst); - return dst; - } - - static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { - Reference dst = new Reference(src.getValue()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertSearchParamType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityModeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventModeEnumFactory()); - VersionConvertor_14_50.copyElement(src, tgt); - switch(src.getValue()) { - case SENDER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.SENDER); - break; - case RECEIVER: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.RECEIVER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) - return Parameters14_50.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Bundle) - return Bundle14_50.convertBundle((org.hl7.fhir.dstu2016may.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CodeSystem) - return CodeSystem14_50.convertCodeSystem((org.hl7.fhir.dstu2016may.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.CompartmentDefinition) - return CompartmentDefinition14_50.convertCompartmentDefinition((org.hl7.fhir.dstu2016may.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ConceptMap) - return ConceptMap14_50.convertConceptMap((org.hl7.fhir.dstu2016may.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Conformance) - return Conformance14_50.convertConformance((org.hl7.fhir.dstu2016may.model.Conformance) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.DataElement) - return DataElement14_50.convertDataElement((org.hl7.fhir.dstu2016may.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ImplementationGuide) - return ImplementationGuide14_50.convertImplementationGuide((org.hl7.fhir.dstu2016may.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.NamingSystem) - return NamingSystem14_50.convertNamingSystem((org.hl7.fhir.dstu2016may.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OperationDefinition) - return OperationDefinition14_50.convertOperationDefinition((org.hl7.fhir.dstu2016may.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.OperationOutcome) - return OperationOutcome14_50.convertOperationOutcome((org.hl7.fhir.dstu2016may.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.Questionnaire) - return Questionnaire14_50.convertQuestionnaire((org.hl7.fhir.dstu2016may.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) - return QuestionnaireResponse14_50.convertQuestionnaireResponse((org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.SearchParameter) - return SearchParameter14_50.convertSearchParameter((org.hl7.fhir.dstu2016may.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StructureDefinition) - return StructureDefinition14_50.convertStructureDefinition((org.hl7.fhir.dstu2016may.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.StructureMap) - return StructureMap14_50.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src); - if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) - return ValueSet14_50.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - if (src instanceof org.hl7.fhir.r5.model.Parameters) - return Parameters14_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); - if (src instanceof org.hl7.fhir.r5.model.Bundle) - return Bundle14_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src); - if (src instanceof org.hl7.fhir.r5.model.CodeSystem) - return CodeSystem14_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition) - return CompartmentDefinition14_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.ConceptMap) - return ConceptMap14_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) - return Conformance14_50.convertConformance((org.hl7.fhir.r5.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) - return ImplementationGuide14_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r5.model.NamingSystem) - return NamingSystem14_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) - return OperationDefinition14_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) - return OperationOutcome14_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r5.model.Questionnaire) - return Questionnaire14_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) - return QuestionnaireResponse14_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r5.model.SearchParameter) - return SearchParameter14_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) - return StructureDefinition14_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.StructureMap) - return StructureMap14_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src); - if (src instanceof org.hl7.fhir.r5.model.ValueSet) - return ValueSet14_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "Bundle", "CodeSystem", "CompartmentDefinition", "ConceptMap", "CapabilityStatement", "ImplementationGuide", "NamingSystem", "OperationDefinition", "OperationOutcome", "Questionnaire", "QuestionnaireResponse", "SearchParameter", "StructureDefinition", "StructureMap", "ValueSet"); - } + tgt.addProfile(u.getValue()); + } + } else { + for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { + tgt.addProfile(u.getValue()); + } + } + for (org.hl7.fhir.r5.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.dstu2016may.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregationElement().setValue(a.getValue())); + } + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + } + + static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpression(convertToR4Expression(src.getExpression())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKeyElement()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHumanElement()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpression(convertTo2016MayExpression(src.getExpression())); + if (src.hasXpathElement()) tgt.setXpathElement(convertString(src.getXpathElement())); + return tgt; + } + + public static String convertToR4Expression(String oldExpression) { + String pass1 = oldExpression.replaceAll("\\$context", "%context").replaceAll("\\$resource", "%resource").replaceAll("code\\+profile", "code&profile").replaceAll("path\\+'\\.'", "path&'.'").replaceAll("fullUrl\\+resource", "fullUrl&resource"); + String pass2 = pass1; + if (pass1.endsWith(".distinct()")) pass2 = pass1.substring(0, pass2.length() - 11) + ".isDistinct()"; + String pass3 = pass2; + if (pass2.endsWith(".empty() or (type.count() = 1)")) + pass3 = pass2.substring(0, pass2.length() - 30) + ".empty() or (type.count() <= 1)"; + String pass4 = pass3; + if (pass3.equals("duration >= 0")) pass4 = "duration.exists() implies duration >= 0"; + else if (pass3.equals("period >= 0")) pass4 = "period.exists() implies period >= 0"; + else if (pass3.equals("fullUrl.empty() xor resource")) pass4 = "fullUrl.empty() xor resource.exists()"; + return pass4; + } + + public static String convertTo2016MayExpression(String newExpression) { + String pass1 = newExpression.replaceAll("%context", "\\$context").replaceAll("%resource", "\\$resource").replaceAll("code&profile", "code+profile").replaceAll("path&'\\.'", "path+'.'").replaceAll("fullUrl%resource", "fullUrl+resource"); + String pass2 = pass1; + if (pass1.endsWith(".isDistinct()")) pass2 = pass1.substring(0, pass1.length() - 13) + ".distinct()"; + String pass3 = pass2; + if (pass2.endsWith(".empty() or (type.count() <= 1)")) + pass3 = pass2.substring(0, pass2.length() - 31) + ".empty() or (type.count() = 1)"; + String pass4 = pass3; + if (pass3.equals("duration.exists() implies duration >= 0")) pass4 = "duration >= 0"; + else if (pass3.equals("period.exists() implies period >= 0")) pass4 = "period >= 0"; + else if (pass3.equals("fullUrl.empty() xor resource.exists()")) pass4 = "fullUrl.empty() xor resource"; + return pass4; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + org.hl7.fhir.r5.model.DataType t = convertType(src.getValueSet()); + if (t instanceof org.hl7.fhir.r5.model.Reference) + tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference()); + else tgt.setValueSet(t.primitiveValue()); + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.Reference(src.getValueSet())); + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertBindingStrength(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentityElement()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMapElement()) tgt.setMapElement(convertString(src.getMapElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.dstu2016may.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.HumanName tgt = new org.hl7.fhir.dstu2016may.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.addFamily(src.getFamily()); + for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.HumanName.NameUseEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.dstu2016may.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu2016may.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu2016may.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case HS: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu2016may.model.SimpleQuantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.SimpleQuantity tgt = new org.hl7.fhir.r5.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.SimpleQuantity tgt = new org.hl7.fhir.dstu2016may.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2016may.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu2016may.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu2016may.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeType) + return convertCode((org.hl7.fhir.dstu2016may.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DateType) + return convertDate((org.hl7.fhir.dstu2016may.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu2016may.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu2016may.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.IdType) + return convertId((org.hl7.fhir.dstu2016may.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.InstantType) + return convertInstant((org.hl7.fhir.dstu2016may.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu2016may.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OidType) + return convertOid((org.hl7.fhir.dstu2016may.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu2016may.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StringType) + return convertString((org.hl7.fhir.dstu2016may.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.TimeType) + return convertTime((org.hl7.fhir.dstu2016may.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu2016may.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu2016may.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UriType) + return convertUri((org.hl7.fhir.dstu2016may.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.UuidType) + return convertUuid((org.hl7.fhir.dstu2016may.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Extension) + return convertExtension((org.hl7.fhir.dstu2016may.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu2016may.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Age) return convertAge((org.hl7.fhir.dstu2016may.model.Age) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu2016may.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu2016may.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu2016may.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Coding) + return convertCoding((org.hl7.fhir.dstu2016may.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Count) + return convertCount((org.hl7.fhir.dstu2016may.model.Count) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Distance) + return convertDistance((org.hl7.fhir.dstu2016may.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Duration) + return convertDuration((org.hl7.fhir.dstu2016may.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu2016may.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Money) + return convertMoney((org.hl7.fhir.dstu2016may.model.Money) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Period) + return convertPeriod((org.hl7.fhir.dstu2016may.model.Period) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu2016may.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Range) + return convertRange((org.hl7.fhir.dstu2016may.model.Range) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Ratio) + return convertRatio((org.hl7.fhir.dstu2016may.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Reference) + return convertReference((org.hl7.fhir.dstu2016may.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu2016may.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Signature) + return convertSignature((org.hl7.fhir.dstu2016may.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Address) + return convertAddress((org.hl7.fhir.dstu2016may.model.Address) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu2016may.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu2016may.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Meta) + return convertMeta((org.hl7.fhir.dstu2016may.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Timing) + return convertTiming((org.hl7.fhir.dstu2016may.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2016may.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r5.model.BooleanType) + return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r5.model.CodeType) return convertCode((org.hl7.fhir.r5.model.CodeType) src); + if (src instanceof org.hl7.fhir.r5.model.DateType) return convertDate((org.hl7.fhir.r5.model.DateType) src); + if (src instanceof org.hl7.fhir.r5.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r5.model.DecimalType) + return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r5.model.IdType) return convertId((org.hl7.fhir.r5.model.IdType) src); + if (src instanceof org.hl7.fhir.r5.model.InstantType) + return convertInstant((org.hl7.fhir.r5.model.InstantType) src); + if (src instanceof org.hl7.fhir.r5.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r5.model.OidType) return convertOid((org.hl7.fhir.r5.model.OidType) src); + if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r5.model.StringType) return convertString((org.hl7.fhir.r5.model.StringType) src); + if (src instanceof org.hl7.fhir.r5.model.TimeType) return convertTime((org.hl7.fhir.r5.model.TimeType) src); + if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r5.model.IntegerType) + return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r5.model.UriType) return convertUri((org.hl7.fhir.r5.model.UriType) src); + if (src instanceof org.hl7.fhir.r5.model.UuidType) return convertUuid((org.hl7.fhir.r5.model.UuidType) src); + if (src instanceof org.hl7.fhir.r5.model.Extension) return convertExtension((org.hl7.fhir.r5.model.Extension) src); + if (src instanceof org.hl7.fhir.r5.model.Narrative) return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); + if (src instanceof org.hl7.fhir.r5.model.Age) return convertAge((org.hl7.fhir.r5.model.Age) src); + if (src instanceof org.hl7.fhir.r5.model.Annotation) + return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); + if (src instanceof org.hl7.fhir.r5.model.Attachment) + return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); + if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r5.model.Coding) return convertCoding((org.hl7.fhir.r5.model.Coding) src); + if (src instanceof org.hl7.fhir.r5.model.Count) return convertCount((org.hl7.fhir.r5.model.Count) src); + if (src instanceof org.hl7.fhir.r5.model.Distance) return convertDistance((org.hl7.fhir.r5.model.Distance) src); + if (src instanceof org.hl7.fhir.r5.model.Duration) return convertDuration((org.hl7.fhir.r5.model.Duration) src); + if (src instanceof org.hl7.fhir.r5.model.Identifier) + return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); + if (src instanceof org.hl7.fhir.r5.model.Money) return convertMoney((org.hl7.fhir.r5.model.Money) src); + if (src instanceof org.hl7.fhir.r5.model.Period) return convertPeriod((org.hl7.fhir.r5.model.Period) src); + if (src instanceof org.hl7.fhir.r5.model.Quantity) return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); + if (src instanceof org.hl7.fhir.r5.model.Range) return convertRange((org.hl7.fhir.r5.model.Range) src); + if (src instanceof org.hl7.fhir.r5.model.Ratio) return convertRatio((org.hl7.fhir.r5.model.Ratio) src); + if (src instanceof org.hl7.fhir.r5.model.Reference) return convertReference((org.hl7.fhir.r5.model.Reference) src); + if (src instanceof org.hl7.fhir.r5.model.SampledData) + return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); + if (src instanceof org.hl7.fhir.r5.model.Signature) return convertSignature((org.hl7.fhir.r5.model.Signature) src); + if (src instanceof org.hl7.fhir.r5.model.Address) return convertAddress((org.hl7.fhir.r5.model.Address) src); + if (src instanceof org.hl7.fhir.r5.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r5.model.HumanName) return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); + if (src instanceof org.hl7.fhir.r5.model.Meta) return convertMeta((org.hl7.fhir.r5.model.Meta) src); + if (src instanceof org.hl7.fhir.r5.model.Timing) return convertTiming((org.hl7.fhir.r5.model.Timing) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; + } + + static public void copyDomainResource(org.hl7.fhir.dstu2016may.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu2016may.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.dstu2016may.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu2016may.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) + if (!isExemptExtension(t.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t)); + } + + static public void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + public static org.hl7.fhir.r5.model.Binary convertBinary(org.hl7.fhir.dstu2016may.model.Binary src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Binary tgt = new org.hl7.fhir.r5.model.Binary(); + copyResource(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasContent()) tgt.setContent(src.getContent()); + return tgt; + } + + public static org.hl7.fhir.dstu2016may.model.Binary convertBinary(org.hl7.fhir.r5.model.Binary src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Binary tgt = new org.hl7.fhir.dstu2016may.model.Binary(); + copyResource(src, tgt); + if (src.hasContentTypeElement()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + tgt.setContentElement(convertBase64Binary(src.getContentElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceResourceStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.RETIRED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus.NULL); + break; + } + } + return tgt; + } + + static public boolean isJurisdiction(CodeableConcept t) { + return t.hasCoding() && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); + } + + public static org.hl7.fhir.r5.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2016may.model.CodeableConcept t) throws FHIRException { + org.hl7.fhir.r5.model.UsageContext result = new org.hl7.fhir.r5.model.UsageContext(); + result.setValue(convertCodeableConcept(t)); + return result; + } + + static public class SourceElementComponentWrapper { + public SourceElementComponentWrapper(SourceElementComponent comp, String source, String target) { + super(); + this.source = source; + this.target = target; + this.comp = comp; + } + + public String source; + public String target; + public org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent comp; + } + + static public CanonicalType convertReferenceToCanonical(Reference src) throws FHIRException { + CanonicalType dst = new CanonicalType(src.getReference()); + copyElement(src, dst); + return dst; + } + + static public Reference convertCanonicalToReference(CanonicalType src) throws FHIRException { + Reference dst = new Reference(src.getValue()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertSearchParamType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConformanceEventMode(org.hl7.fhir.dstu2016may.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityModeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.CapabilityStatement.EventCapabilityMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu2016may.model.Enumeration convertConformanceEventMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu2016may.model.Enumeration tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventModeEnumFactory()); + VersionConvertor_14_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.NULL); + } else { + switch (src.getValue()) { + case SENDER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.SENDER); + break; + case RECEIVER: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.RECEIVER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu2016may.model.Conformance.ConformanceEventMode.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.dstu2016may.model.Parameters) + return Parameters14_50.convertParameters((org.hl7.fhir.dstu2016may.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Bundle) + return Bundle14_50.convertBundle((org.hl7.fhir.dstu2016may.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CodeSystem) + return CodeSystem14_50.convertCodeSystem((org.hl7.fhir.dstu2016may.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.CompartmentDefinition) + return CompartmentDefinition14_50.convertCompartmentDefinition((org.hl7.fhir.dstu2016may.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ConceptMap) + return ConceptMap14_50.convertConceptMap((org.hl7.fhir.dstu2016may.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Conformance) + return Conformance14_50.convertConformance((org.hl7.fhir.dstu2016may.model.Conformance) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.DataElement) + return DataElement14_50.convertDataElement((org.hl7.fhir.dstu2016may.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ImplementationGuide) + return ImplementationGuide14_50.convertImplementationGuide((org.hl7.fhir.dstu2016may.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.NamingSystem) + return NamingSystem14_50.convertNamingSystem((org.hl7.fhir.dstu2016may.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OperationDefinition) + return OperationDefinition14_50.convertOperationDefinition((org.hl7.fhir.dstu2016may.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.OperationOutcome) + return OperationOutcome14_50.convertOperationOutcome((org.hl7.fhir.dstu2016may.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.Questionnaire) + return Questionnaire14_50.convertQuestionnaire((org.hl7.fhir.dstu2016may.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) + return QuestionnaireResponse14_50.convertQuestionnaireResponse((org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.SearchParameter) + return SearchParameter14_50.convertSearchParameter((org.hl7.fhir.dstu2016may.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StructureDefinition) + return StructureDefinition14_50.convertStructureDefinition((org.hl7.fhir.dstu2016may.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.StructureMap) + return StructureMap14_50.convertStructureMap((org.hl7.fhir.dstu2016may.model.StructureMap) src); + if (src instanceof org.hl7.fhir.dstu2016may.model.ValueSet) + return ValueSet14_50.convertValueSet((org.hl7.fhir.dstu2016may.model.ValueSet) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static org.hl7.fhir.dstu2016may.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + if (src instanceof org.hl7.fhir.r5.model.Parameters) + return Parameters14_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); + if (src instanceof org.hl7.fhir.r5.model.Bundle) + return Bundle14_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src); + if (src instanceof org.hl7.fhir.r5.model.CodeSystem) + return CodeSystem14_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition) + return CompartmentDefinition14_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.ConceptMap) + return ConceptMap14_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) + return Conformance14_50.convertConformance((org.hl7.fhir.r5.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) + return ImplementationGuide14_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r5.model.NamingSystem) + return NamingSystem14_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) + return OperationDefinition14_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) + return OperationOutcome14_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r5.model.Questionnaire) + return Questionnaire14_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) + return QuestionnaireResponse14_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r5.model.SearchParameter) + return SearchParameter14_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) + return StructureDefinition14_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.StructureMap) + return StructureMap14_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src); + if (src instanceof org.hl7.fhir.r5.model.ValueSet) + return ValueSet14_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "Bundle", "CodeSystem", "CompartmentDefinition", "ConceptMap", "CapabilityStatement", "ImplementationGuide", "NamingSystem", "OperationDefinition", "OperationOutcome", "Questionnaire", "QuestionnaireResponse", "SearchParameter", "StructureDefinition", "StructureMap", "ValueSet"); + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java index af922aba6..04689a6a7 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java @@ -1,9 +1,5 @@ package org.hl7.fhir.convertors; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - import org.hl7.fhir.convertors.conv30_40.*; import org.hl7.fhir.dstu3.model.Parameters; import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent; @@ -14,5207 +10,4681 @@ import org.hl7.fhir.r4.model.Type; import org.hl7.fhir.r4.model.UriType; import org.hl7.fhir.utilities.Utilities; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + /* Copyright (c) 2011+, HL7, Inc. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + */ + public class VersionConvertor_30_40 { + static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"; + static public List CANONICAL_URLS = new ArrayList<>(); - static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"; + static { + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + } - static public List CANONICAL_URLS = new ArrayList<>(); - - static { - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } } + } - static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } + static public void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + static public void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + static public void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDateTimeToDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { + org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { + org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { + org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { + org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { + org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { + org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); + copyElement(src, tgt); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu3.model.Reference) + tgt.setValue(convertReferenceToCanonical((org.hl7.fhir.dstu3.model.Reference) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); + copyElement(src, tgt); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) + tgt.setValue(convertCanonicalToReference((org.hl7.fhir.r4.model.CanonicalType) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + tgt.setCode(src.getValue()); + return tgt; + } + + public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + if (src.hasCoding()) { + if (src.getCodingFirstRep().hasSystem()) tgt.setSystem(src.getCodingFirstRep().getSystem()); + if (src.getCodingFirstRep().hasVersion()) tgt.setVersion(src.getCodingFirstRep().getVersion()); + if (src.getCodingFirstRep().hasCode()) tgt.setCode(src.getCodingFirstRep().getCode()); + if (src.getCodingFirstRep().hasDisplay()) tgt.setDisplay(src.getCodingFirstRep().getDisplay()); + if (src.getCodingFirstRep().hasUserSelected()) tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); + copyElement(src, tgt); + if (src.hasCoding()) { + if (src.getCodingFirstRep().hasSystem()) tgt.setSystem(src.getCodingFirstRep().getSystem()); + if (src.getCodingFirstRep().hasVersion()) tgt.setVersion(src.getCodingFirstRep().getVersion()); + if (src.getCodingFirstRep().hasCode()) tgt.setCode(src.getCodingFirstRep().getCode()); + if (src.getCodingFirstRep().hasDisplay()) tgt.setDisplay(src.getCodingFirstRep().getDisplay()); + if (src.getCodingFirstRep().hasUserSelected()) tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCode()) tgt.setCurrencyElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrency()) tgt.setCodeElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static void copyQuantity(org.hl7.fhir.dstu3.model.Quantity src, org.hl7.fhir.r4.model.Quantity tgt) throws FHIRException { + if (src == null || tgt == null) return; + copyElement(src, tgt); + if (src.hasValue()) tgt.setValue(src.getValue()); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnit(src.getUnit()); + if (src.hasSystem()) tgt.setSystem(src.getSystem()); + if (src.hasCode()) tgt.setCode(src.getCode()); + } + + public static void copyQuantity(org.hl7.fhir.r4.model.Quantity src, org.hl7.fhir.dstu3.model.Quantity tgt) throws FHIRException { + if (src == null || tgt == null) return; + copyElement(src, tgt); + if (src.hasValue()) tgt.setValue(src.getValue()); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnit(src.getUnit()); + if (src.hasSystem()) tgt.setSystem(src.getSystem()); + if (src.hasCode()) tgt.setCode(src.getCode()); + } + + public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensions()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasData()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensions()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasData()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhen()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) { + if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); + else tgt.setWho(convertReference(src.getWhoReference())); + } + if (src.hasOnBehalfOf()) { + if (src.hasOnBehalfOfUriType()) tgt.setOnBehalfOf(new Reference(src.getOnBehalfOfUriType().primitiveValue())); + else tgt.setOnBehalfOf(convertReference(src.getOnBehalfOfReference())); + } + if (src.hasContentType()) tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); + if (src.hasBlob()) tgt.setDataElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhen()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasOnBehalfOf()) tgt.setOnBehalfOf(convertType(src.getOnBehalfOf())); + if (src.hasSigFormat()) tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); + if (src.hasData()) tgt.setBlobElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ContactDetail convertContactDetail(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ContactDetail convertContactDetail(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL); + break; + case SMS: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL); + break; + case SMS: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.SMS); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Contributor convertContributor(org.hl7.fhir.dstu3.model.Contributor src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Contributor tgt = new org.hl7.fhir.r4.model.Contributor(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Contributor convertContributor(org.hl7.fhir.r4.model.Contributor src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Contributor tgt = new org.hl7.fhir.dstu3.model.Contributor(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContributorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Contributor.ContributorTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL); + } else { + switch (src.getValue()) { + case AUTHOR: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.AUTHOR); + break; + case EDITOR: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.EDITOR); + break; + case REVIEWER: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.REVIEWER); + break; + case ENDORSER: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.ENDORSER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContributorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Contributor.ContributorTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL); + } else { + switch (src.getValue()) { + case AUTHOR: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.AUTHOR); + break; + case EDITOR: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.EDITOR); + break; + case REVIEWER: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.REVIEWER); + break; + case ENDORSER: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.ENDORSER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Dosage convertDosage(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); + copyElement(src, tgt); + if (src.hasSequence()) tgt.setSequenceElement(convertInteger(src.getSequenceElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAdditionalInstruction()) + tgt.addAdditionalInstruction(convertCodeableConcept(t)); + if (src.hasPatientInstruction()) + tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertCodeableConcept(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose() || src.hasRate()) { + org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); + if (src.hasDose()) dr.setDose(convertType(src.getDose())); + if (src.hasRate()) dr.setRate(convertType(src.getRate())); + } + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasMaxDosePerAdministration()) + tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); + if (src.hasMaxDosePerLifetime()) tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Dosage convertDosage(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); + copyElement(src, tgt); + if (src.hasSequence()) tgt.setSequenceElement(convertInteger(src.getSequenceElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAdditionalInstruction()) + tgt.addAdditionalInstruction(convertCodeableConcept(t)); + if (src.hasPatientInstruction()) + tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertCodeableConcept(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) { + if (src.getDoseAndRate().get(0).getDose() instanceof org.hl7.fhir.r4.model.Quantity) { + tgt.setDose(convertSimpleQuantity((org.hl7.fhir.r4.model.Quantity) src.getDoseAndRate().get(0).getDose())); + } else { + tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); + } + } + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasMaxDosePerAdministration()) + tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); + if (src.hasMaxDosePerLifetime()) tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) { + if (src.getDoseAndRate().get(0).getRate() instanceof org.hl7.fhir.r4.model.Quantity) { + tgt.setRate(convertSimpleQuantity((org.hl7.fhir.r4.model.Quantity) src.getDoseAndRate().get(0).getRate())); + } else { + tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_30_40::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setSliceNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) + tgt.addExample(convertElementDefinitionExampleComponent(t)); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (tgt.getIsModifier()) { + String reason = org.hl7.fhir.dstu3.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); + if (Utilities.noString(reason)) reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; + tgt.setIsModifierReason(reason); + } + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_30_40::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setSliceNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) + tgt.addExample(convertElementDefinitionExampleComponent(t)); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) + org.hl7.fhir.dstu3.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + case XHTML: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XHTML); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + case XHTML: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XHTML); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertDiscriminatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL); + } else { + switch (src.getValue()) { + case VALUE: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.VALUE); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.EXISTS); + break; + case PATTERN: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PATTERN); + break; + case TYPE: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.TYPE); + break; + case PROFILE: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PROFILE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL); + } else { + switch (src.getValue()) { + case VALUE: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.VALUE); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.EXISTS); + break; + case PATTERN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PATTERN); + break; + case TYPE: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.TYPE); + break; + case PROFILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PROFILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static void convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = null; + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : list) + if (t.getCode().equals(src.getCode())) tgt = t; + if (tgt == null) { + tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCodeElement(convertUri(src.getCodeElement())); + } + if (src.hasProfile()) tgt.addProfile(src.getProfile()); + if (src.hasTargetProfile()) tgt.addTargetProfile(src.getTargetProfile()); + for (org.hl7.fhir.dstu3.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.r4.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue())); + } + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + } + + public static void convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCodeElement(convertUri(src.getCodeElement())); + list.add(tgt); + if (src.hasTarget()) { + if (src.hasProfile()) tgt.setProfile(src.getProfile().get(0).getValue()); + for (org.hl7.fhir.r4.model.UriType u : src.getTargetProfile()) { + if (tgt.hasTargetProfile()) { + tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + if (src.hasProfile()) tgt.setProfile(src.getProfile().get(0).getValue()); } - } - - static public void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } + tgt.setTargetProfile(u.getValue()); + } + } else { + for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { + if (tgt.hasProfile()) { + tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); } - } - - static public void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - static public void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDateTimeToDate(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValue()) : new org.hl7.fhir.r4.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); - copyElement(src, tgt); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu3.model.Reference) - tgt.setValue(convertReferenceToCanonical((org.hl7.fhir.dstu3.model.Reference) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); - copyElement(src, tgt); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) - tgt.setValue(convertCanonicalToReference((org.hl7.fhir.r4.model.CanonicalType) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - tgt.setCode(src.getValue()); - return tgt; - } - - public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - if (src.hasCoding()) { - if (src.getCodingFirstRep().hasSystem()) - tgt.setSystem(src.getCodingFirstRep().getSystem()); - if (src.getCodingFirstRep().hasVersion()) - tgt.setVersion(src.getCodingFirstRep().getVersion()); - if (src.getCodingFirstRep().hasCode()) - tgt.setCode(src.getCodingFirstRep().getCode()); - if (src.getCodingFirstRep().hasDisplay()) - tgt.setDisplay(src.getCodingFirstRep().getDisplay()); - if (src.getCodingFirstRep().hasUserSelected()) - tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); - copyElement(src, tgt); - if (src.hasCoding()) { - if (src.getCodingFirstRep().hasSystem()) - tgt.setSystem(src.getCodingFirstRep().getSystem()); - if (src.getCodingFirstRep().hasVersion()) - tgt.setVersion(src.getCodingFirstRep().getVersion()); - if (src.getCodingFirstRep().hasCode()) - tgt.setCode(src.getCodingFirstRep().getCode()); - if (src.getCodingFirstRep().hasDisplay()) - tgt.setDisplay(src.getCodingFirstRep().getDisplay()); - if (src.getCodingFirstRep().hasUserSelected()) - tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCode()) - tgt.setCurrencyElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrency()) - tgt.setCodeElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static void copyQuantity(org.hl7.fhir.dstu3.model.Quantity src, org.hl7.fhir.r4.model.Quantity tgt) throws FHIRException { - if (src == null || tgt == null) - return; - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnit(src.getUnit()); - if (src.hasSystem()) - tgt.setSystem(src.getSystem()); - if (src.hasCode()) - tgt.setCode(src.getCode()); - } - - public static void copyQuantity(org.hl7.fhir.r4.model.Quantity src, org.hl7.fhir.dstu3.model.Quantity tgt) throws FHIRException { - if (src == null || tgt == null) - return; - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnit(src.getUnit()); - if (src.hasSystem()) - tgt.setSystem(src.getSystem()); - if (src.hasCode()) - tgt.setCode(src.getCode()); - } - - public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensions()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasData()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensions()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasData()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhen()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) { - if (src.hasWhoUriType()) - tgt.setWho(new org.hl7.fhir.r4.model.Reference(src.getWhoUriType().getValue())); - else - tgt.setWho(convertReference(src.getWhoReference())); - } - if (src.hasOnBehalfOf()) { - if (src.hasOnBehalfOfUriType()) - tgt.setOnBehalfOf(new Reference(src.getOnBehalfOfUriType().primitiveValue())); - else - tgt.setOnBehalfOf(convertReference(src.getOnBehalfOfReference())); - } - if (src.hasContentType()) - tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); - if (src.hasBlob()) - tgt.setDataElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhen()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasOnBehalfOf()) - tgt.setOnBehalfOf(convertType(src.getOnBehalfOf())); - if (src.hasSigFormat()) - tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); - if (src.hasData()) - tgt.setBlobElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ContactDetail convertContactDetail(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ContactDetail convertContactDetail(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL); - break; - case SMS: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL); - break; - case SMS: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.SMS); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Contributor convertContributor(org.hl7.fhir.dstu3.model.Contributor src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Contributor tgt = new org.hl7.fhir.r4.model.Contributor(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertContributorType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Contributor convertContributor(org.hl7.fhir.r4.model.Contributor src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Contributor tgt = new org.hl7.fhir.dstu3.model.Contributor(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertContributorType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContributorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Contributor.ContributorTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case AUTHOR: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.AUTHOR); - break; - case EDITOR: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.EDITOR); - break; - case REVIEWER: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.REVIEWER); - break; - case ENDORSER: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.ENDORSER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContributorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Contributor.ContributorTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case AUTHOR: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.AUTHOR); - break; - case EDITOR: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.EDITOR); - break; - case REVIEWER: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.REVIEWER); - break; - case ENDORSER: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.ENDORSER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Dosage convertDosage(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); - copyElement(src, tgt); - if (src.hasSequence()) - tgt.setSequenceElement(convertInteger(src.getSequenceElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAdditionalInstruction()) - tgt.addAdditionalInstruction(convertCodeableConcept(t)); - if (src.hasPatientInstruction()) - tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertCodeableConcept(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose() || src.hasRate()) { - org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); - if (src.hasDose()) - dr.setDose(convertType(src.getDose())); - if (src.hasRate()) - dr.setRate(convertType(src.getRate())); - } - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - if (src.hasMaxDosePerAdministration()) - tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); - if (src.hasMaxDosePerLifetime()) - tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Dosage convertDosage(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); - copyElement(src, tgt); - if (src.hasSequence()) - tgt.setSequenceElement(convertInteger(src.getSequenceElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAdditionalInstruction()) - tgt.addAdditionalInstruction(convertCodeableConcept(t)); - if (src.hasPatientInstruction()) - tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertCodeableConcept(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) { - if (src.getDoseAndRate().get(0).getDose() instanceof org.hl7.fhir.r4.model.Quantity) { - tgt.setDose(convertSimpleQuantity((org.hl7.fhir.r4.model.Quantity) src.getDoseAndRate().get(0).getDose())); - } else { - tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); - } - } - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - if (src.hasMaxDosePerAdministration()) - tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); - if (src.hasMaxDosePerLifetime()) - tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) { - if (src.getDoseAndRate().get(0).getRate() instanceof org.hl7.fhir.r4.model.Quantity) { - tgt.setRate(convertSimpleQuantity((org.hl7.fhir.r4.model.Quantity) src.getDoseAndRate().get(0).getRate())); - } else { - tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); - } - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_30_40::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setSliceNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) - convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasOrderMeaning()) - tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) - tgt.addExample(convertElementDefinitionExampleComponent(t)); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) - tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (tgt.getIsModifier()) { - String reason = org.hl7.fhir.dstu3.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); - if (Utilities.noString(reason)) - reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; - tgt.setIsModifierReason(reason); - } - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) - tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_30_40::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setSliceNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) - convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasOrderMeaning()) - tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) - tgt.addExample(convertElementDefinitionExampleComponent(t)); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) - tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) - org.hl7.fhir.dstu3.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) - tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - case XHTML: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XHTML); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - case XHTML: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XHTML); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) - tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) - tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertDiscriminatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case VALUE: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.VALUE); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.EXISTS); - break; - case PATTERN: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PATTERN); - break; - case TYPE: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.TYPE); - break; - case PROFILE: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PROFILE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case VALUE: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.VALUE); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.EXISTS); - break; - case PATTERN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PATTERN); - break; - case TYPE: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.TYPE); - break; - case PROFILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PROFILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static void convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = null; - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : list) - if (t.getCode().equals(src.getCode())) - tgt = t; - if (tgt == null) { - tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCodeElement(convertUri(src.getCodeElement())); - } - if (src.hasProfile()) - tgt.addProfile(src.getProfile()); - if (src.hasTargetProfile()) - tgt.addTargetProfile(src.getTargetProfile()); - for (org.hl7.fhir.dstu3.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.r4.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregation(a.getValue())); - } - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - } - - public static void convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCodeElement(convertUri(src.getCodeElement())); - list.add(tgt); - if (src.hasTarget()) { - if (src.hasProfile()) - tgt.setProfile(src.getProfile().get(0).getValue()); - for (org.hl7.fhir.r4.model.UriType u : src.getTargetProfile()) { - if (tgt.hasTargetProfile()) { - tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - if (src.hasProfile()) - tgt.setProfile(src.getProfile().get(0).getValue()); - } - tgt.setTargetProfile(u.getValue()); - } + tgt.setProfile(u.getValue()); + } + } + } + + static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKey()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHuman()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpath()) tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasSource()) tgt.setSource(src.getSource()); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKey()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHuman()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpath()) tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasSource()) tgt.setSource(src.getSource()); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt, EXT_SRC_TYPE); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + Type t = convertType(src.getValueSet()); + if (t instanceof org.hl7.fhir.r4.model.Reference) { + tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); + tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("Reference")); + } else { + tgt.setValueSet(t.primitiveValue()); + tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("uri")); + } + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt, EXT_SRC_TYPE); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + org.hl7.fhir.r4.model.Extension ex = src.getValueSetElement().getExtensionByUrl(EXT_SRC_TYPE); + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (ex != null) { + if ("uri".equals(ex.getValue().primitiveValue())) { + tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr == null ? src.getValueSet() : vsr)); } else { - for (org.hl7.fhir.r4.model.UriType u : src.getProfile()) { - if (tgt.hasProfile()) { - tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - } - tgt.setProfile(u.getValue()); - } + tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); } - } - - static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKey()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHuman()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpath()) - tgt.setXpathElement(convertString(src.getXpathElement())); - if (src.hasSource()) - tgt.setSource(src.getSource()); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKey()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHuman()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpath()) - tgt.setXpathElement(convertString(src.getXpathElement())); - if (src.hasSource()) - tgt.setSource(src.getSource()); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt, EXT_SRC_TYPE); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - Type t = convertType(src.getValueSet()); - if (t instanceof org.hl7.fhir.r4.model.Reference) { - tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); - tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("Reference")); - } else { - tgt.setValueSet(t.primitiveValue()); - tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("uri")); - } - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt, EXT_SRC_TYPE); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - org.hl7.fhir.r4.model.Extension ex = src.getValueSetElement().getExtensionByUrl(EXT_SRC_TYPE); - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (ex != null) { - if ("uri".equals(ex.getValue().primitiveValue())) { - tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr == null ? src.getValueSet() : vsr)); - } else { - tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); - } - } else { - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); - } - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentity()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMap()) - tgt.setMapElement(convertString(src.getMapElement())); - if (src.hasComment()) - tgt.setCommentElement(convertString(src.getCommentElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentity()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMap()) - tgt.setMapElement(convertString(src.getMapElement())); - if (src.hasComment()) - tgt.setCommentElement(convertString(src.getCommentElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.setFamilyElement(convertString(src.getFamilyElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.setFamilyElement(convertString(src.getFamilyElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.dstu3.model.ParameterDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ParameterDefinition tgt = new org.hl7.fhir.r4.model.ParameterDefinition(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertCode(src.getNameElement())); - if (src.hasUse()) - tgt.setUseElement(convertParameterUse(src.getUseElement())); - if (src.hasMin()) - tgt.setMinElement(convertInteger(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasDocumentation()) - tgt.setDocumentationElement(convertString(src.getDocumentationElement())); - if (src.hasType()) - tgt.setTypeElement(convertCode(src.getTypeElement())); - if (src.hasProfile()) { - tgt.setProfile(convertReference(src.getProfile()).getReference()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ParameterDefinition tgt = new org.hl7.fhir.dstu3.model.ParameterDefinition(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertCode(src.getNameElement())); - if (src.hasUse()) - tgt.setUseElement(convertParameterUse(src.getUseElement())); - if (src.hasMin()) - tgt.setMinElement(convertInteger(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasDocumentation()) - tgt.setDocumentationElement(convertString(src.getDocumentationElement())); - if (src.hasType()) - tgt.setTypeElement(convertCode(src.getTypeElement())); - if (src.hasProfile()) - tgt.setProfile(new org.hl7.fhir.dstu3.model.Reference(src.getProfile())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertParameterUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ParameterDefinition.ParameterUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case IN: - tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.IN); - break; - case OUT: - tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.OUT); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertParameterUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUseEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case IN: - tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.IN); - break; - case OUT: - tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.OUT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.RelatedArtifact tgt = new org.hl7.fhir.r4.model.RelatedArtifact(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasCitation()) - tgt.setCitation(src.getCitation()); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasDocument()) - tgt.setDocument(convertAttachment(src.getDocument())); - if (src.hasResource()) - tgt.setResourceElement(convertReferenceToCanonical(src.getResource())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.RelatedArtifact tgt = new org.hl7.fhir.dstu3.model.RelatedArtifact(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasCitation()) - tgt.setCitation(src.getCitation()); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasDocument()) - tgt.setDocument(convertAttachment(src.getDocument())); - if (src.hasResource()) - tgt.setResource(convertCanonicalToReference(src.getResourceElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case DOCUMENTATION: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); - break; - case JUSTIFICATION: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); - break; - case CITATION: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.CITATION); - break; - case PREDECESSOR: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); - break; - case SUCCESSOR: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); - break; - case DERIVEDFROM: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); - break; - case DEPENDSON: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - break; - case COMPOSEDOF: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case DOCUMENTATION: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); - break; - case JUSTIFICATION: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); - break; - case CITATION: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.CITATION); - break; - case PREDECESSOR: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); - break; - case SUCCESSOR: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); - break; - case DERIVEDFROM: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); - break; - case DEPENDSON: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - break; - case COMPOSEDOF: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEventElement().setValueAsString(t.getValueAsString()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.addEventElement().setValueAsString(t.getValueAsString()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - tgt.setDayOfWeek(src.getDayOfWeek().stream() - .map(VersionConvertor_30_40::convertDayOfWeek) - .collect(Collectors.toList())); - for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); - tgt.setWhen(src.getWhen().stream() - .map(VersionConvertor_30_40::convertEventTiming) - .collect(Collectors.toList())); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - tgt.setDayOfWeek(src.getDayOfWeek().stream() - .map(VersionConvertor_30_40::convertDayOfWeek) - .collect(Collectors.toList())); - for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); - tgt.setWhen(src.getWhen().stream() - .map(VersionConvertor_30_40::convertEventTiming) - .collect(Collectors.toList())); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertDayOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.DayOfWeekEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertDayOfWeek(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.DayOfWeekEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MORN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN); - break; - case AFT: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT); - break; - case EVE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE); - break; - case NIGHT: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NIGHT); - break; - case PHS: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PHS); - break; - case HS: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MORN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.MORN); - break; - case AFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AFT); - break; - case EVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.EVE); - break; - case NIGHT: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NIGHT); - break; - case PHS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PHS); - break; - case HS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.UsageContext convertUsageContext(org.hl7.fhir.dstu3.model.UsageContext src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.UsageContext tgt = new org.hl7.fhir.r4.model.UsageContext(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(convertCoding(src.getCode())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UsageContext convertUsageContext(org.hl7.fhir.r4.model.UsageContext src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.UsageContext tgt = new org.hl7.fhir.dstu3.model.UsageContext(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(convertCoding(src.getCode())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.dstu3.model.TriggerDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TriggerDefinition tgt = new org.hl7.fhir.r4.model.TriggerDefinition(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertTriggerType(src.getTypeElement())); - if (src.hasEventName()) - tgt.setNameElement(convertString(src.getEventNameElement())); - if (src.hasEventTiming()) - tgt.setTiming(convertType(src.getEventTiming())); - if (src.hasEventData()) - tgt.addData(convertDataRequirement(src.getEventData())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r4.model.TriggerDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TriggerDefinition tgt = new org.hl7.fhir.dstu3.model.TriggerDefinition(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertTriggerType(src.getTypeElement())); - if (src.hasName()) - tgt.setEventNameElement(convertString(src.getNameElement())); - if (src.hasTiming()) - tgt.setEventTiming(convertType(src.getTiming())); - if (src.hasData()) - tgt.setEventData(convertDataRequirement(src.getDataFirstRep())); - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement convertDataRequirement(org.hl7.fhir.dstu3.model.DataRequirement src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement tgt = new org.hl7.fhir.r4.model.DataRequirement(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertCode(src.getTypeElement())); - for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); - for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) - tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); - for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) - tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DataRequirement convertDataRequirement(org.hl7.fhir.r4.model.DataRequirement src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DataRequirement tgt = new org.hl7.fhir.dstu3.model.DataRequirement(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertCode(src.getTypeElement())); - for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r4.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); - for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) - tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); - for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) - tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValueSet()) { - Type t = convertType(src.getValueSet()); - if (t instanceof org.hl7.fhir.r4.model.Reference) - tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); - else - tgt.setValueSet(t.primitiveValue()); - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - for (org.hl7.fhir.dstu3.model.CodeType t : src.getValueCode()) tgt.addCode(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.Coding t : src.getValueCoding()) tgt.addCode(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getValueCodeableConcept()) tgt.addCode(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValueSet()) { - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); - } - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) { - tgt.addValueCoding(convertCoding(t)); - } - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertTriggerType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TriggerDefinition.TriggerTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case NAMEDEVENT: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NAMEDEVENT); - break; - case PERIODIC: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.PERIODIC); - break; - case DATAADDED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAADDED); - break; - case DATAMODIFIED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAMODIFIED); - break; - case DATAREMOVED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAREMOVED); - break; - case DATAACCESSED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSED); - break; - case DATAACCESSENDED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSENDED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertTriggerType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case NAMEDEVENT: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NAMEDEVENT); - break; - case PERIODIC: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.PERIODIC); - break; - case DATAADDED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAADDED); - break; - case DATAMODIFIED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAMODIFIED); - break; - case DATAREMOVED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAREMOVED); - break; - case DATAACCESSED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSED); - break; - case DATAACCESSENDED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSENDED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeType) - return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateType) - return convertDate((org.hl7.fhir.dstu3.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IdType) - return convertId((org.hl7.fhir.dstu3.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu3.model.InstantType) - return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu3.model.OidType) - return convertOid((org.hl7.fhir.dstu3.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.StringType) - return convertString((org.hl7.fhir.dstu3.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu3.model.TimeType) - return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UuidType) - return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UriType) - return convertUri((org.hl7.fhir.dstu3.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu3.model.Extension) - return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu3.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu3.model.Age) - return convertAge((org.hl7.fhir.dstu3.model.Age) src); - if (src instanceof org.hl7.fhir.dstu3.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu3.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu3.model.Coding) - return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu3.model.Count) - return convertCount((org.hl7.fhir.dstu3.model.Count) src); - if (src instanceof org.hl7.fhir.dstu3.model.Distance) - return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Duration) - return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu3.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu3.model.Money) - return convertMoney((org.hl7.fhir.dstu3.model.Money) src); - if (src instanceof org.hl7.fhir.dstu3.model.Period) - return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); - if (src instanceof org.hl7.fhir.dstu3.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.dstu3.model.SimpleQuantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Range) - return convertRange((org.hl7.fhir.dstu3.model.Range) src); - if (src instanceof org.hl7.fhir.dstu3.model.Ratio) - return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu3.model.Reference) - return convertReference((org.hl7.fhir.dstu3.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu3.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu3.model.Signature) - return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu3.model.Address) - return convertAddress((org.hl7.fhir.dstu3.model.Address) src); - if (src instanceof org.hl7.fhir.dstu3.model.ContactDetail) - return convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) src); - if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu3.model.Contributor) - return convertContributor((org.hl7.fhir.dstu3.model.Contributor) src); - if (src instanceof org.hl7.fhir.dstu3.model.Dosage) - return convertDosage((org.hl7.fhir.dstu3.model.Dosage) src); - if (src instanceof org.hl7.fhir.dstu3.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu3.model.Meta) - return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu3.model.ParameterDefinition) - return convertParameterDefinition((org.hl7.fhir.dstu3.model.ParameterDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.RelatedArtifact) - return convertRelatedArtifact((org.hl7.fhir.dstu3.model.RelatedArtifact) src); - if (src instanceof org.hl7.fhir.dstu3.model.Timing) - return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); - if (src instanceof org.hl7.fhir.dstu3.model.UsageContext) - return convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) src); - if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.DataRequirement) - return convertDataRequirement((org.hl7.fhir.dstu3.model.DataRequirement) src); - if (src instanceof org.hl7.fhir.dstu3.model.TriggerDefinition) - return convertTriggerDefinition((org.hl7.fhir.dstu3.model.TriggerDefinition) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r4.model.BooleanType) - return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r4.model.CodeType) - return convertCode((org.hl7.fhir.r4.model.CodeType) src); - if (src instanceof org.hl7.fhir.r4.model.DateType) - return convertDate((org.hl7.fhir.r4.model.DateType) src); - if (src instanceof org.hl7.fhir.r4.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r4.model.DecimalType) - return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r4.model.IdType) - return convertId((org.hl7.fhir.r4.model.IdType) src); - if (src instanceof org.hl7.fhir.r4.model.InstantType) - return convertInstant((org.hl7.fhir.r4.model.InstantType) src); - if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r4.model.IntegerType) - return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r4.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r4.model.OidType) - return convertOid((org.hl7.fhir.r4.model.OidType) src); - if (src instanceof org.hl7.fhir.r4.model.StringType) - return convertString((org.hl7.fhir.r4.model.StringType) src); - if (src instanceof org.hl7.fhir.r4.model.TimeType) - return convertTime((org.hl7.fhir.r4.model.TimeType) src); - if (src instanceof org.hl7.fhir.r4.model.UuidType) - return convertUuid((org.hl7.fhir.r4.model.UuidType) src); - if (src instanceof org.hl7.fhir.r4.model.UriType) - return convertUri((org.hl7.fhir.r4.model.UriType) src); - if (src instanceof org.hl7.fhir.r4.model.Extension) - return convertExtension((org.hl7.fhir.r4.model.Extension) src); - if (src instanceof org.hl7.fhir.r4.model.Narrative) - return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); - if (src instanceof org.hl7.fhir.r4.model.Age) - return convertAge((org.hl7.fhir.r4.model.Age) src); - if (src instanceof org.hl7.fhir.r4.model.Annotation) - return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); - if (src instanceof org.hl7.fhir.r4.model.Attachment) - return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); - if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r4.model.Coding) - return convertCoding((org.hl7.fhir.r4.model.Coding) src); - if (src instanceof org.hl7.fhir.r4.model.Count) - return convertCount((org.hl7.fhir.r4.model.Count) src); - if (src instanceof org.hl7.fhir.r4.model.Distance) - return convertDistance((org.hl7.fhir.r4.model.Distance) src); - if (src instanceof org.hl7.fhir.r4.model.Duration) - return convertDuration((org.hl7.fhir.r4.model.Duration) src); - if (src instanceof org.hl7.fhir.r4.model.Identifier) - return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); - if (src instanceof org.hl7.fhir.r4.model.Money) - return convertMoney((org.hl7.fhir.r4.model.Money) src); - if (src instanceof org.hl7.fhir.r4.model.Period) - return convertPeriod((org.hl7.fhir.r4.model.Period) src); - if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); - if (src instanceof org.hl7.fhir.r4.model.Quantity) - return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); - if (src instanceof org.hl7.fhir.r4.model.Range) - return convertRange((org.hl7.fhir.r4.model.Range) src); - if (src instanceof org.hl7.fhir.r4.model.Ratio) - return convertRatio((org.hl7.fhir.r4.model.Ratio) src); - if (src instanceof org.hl7.fhir.r4.model.Reference) - return convertReference((org.hl7.fhir.r4.model.Reference) src); - if (src instanceof org.hl7.fhir.r4.model.SampledData) - return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); - if (src instanceof org.hl7.fhir.r4.model.Signature) - return convertSignature((org.hl7.fhir.r4.model.Signature) src); - if (src instanceof org.hl7.fhir.r4.model.Address) - return convertAddress((org.hl7.fhir.r4.model.Address) src); - if (src instanceof org.hl7.fhir.r4.model.ContactDetail) - return convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) src); - if (src instanceof org.hl7.fhir.r4.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r4.model.Contributor) - return convertContributor((org.hl7.fhir.r4.model.Contributor) src); - if (src instanceof org.hl7.fhir.r4.model.Dosage) - return convertDosage((org.hl7.fhir.r4.model.Dosage) src); - if (src instanceof org.hl7.fhir.r4.model.HumanName) - return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); - if (src instanceof org.hl7.fhir.r4.model.Meta) - return convertMeta((org.hl7.fhir.r4.model.Meta) src); - if (src instanceof org.hl7.fhir.r4.model.ParameterDefinition) - return convertParameterDefinition((org.hl7.fhir.r4.model.ParameterDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.RelatedArtifact) - return convertRelatedArtifact((org.hl7.fhir.r4.model.RelatedArtifact) src); - if (src instanceof org.hl7.fhir.r4.model.Timing) - return convertTiming((org.hl7.fhir.r4.model.Timing) src); - if (src instanceof org.hl7.fhir.r4.model.UsageContext) - return convertUsageContext((org.hl7.fhir.r4.model.UsageContext) src); - if (src instanceof org.hl7.fhir.r4.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.DataRequirement) - return convertDataRequirement((org.hl7.fhir.r4.model.DataRequirement) src); - if (src instanceof org.hl7.fhir.r4.model.TriggerDefinition) - return convertTriggerDefinition((org.hl7.fhir.r4.model.TriggerDefinition) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) - if (s.equals(url)) - ok = true; - return ok; - } - - static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); - for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) - if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t2)); - for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) - if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t3)); - } - - static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r4.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); - for (org.hl7.fhir.r4.model.Extension t2 : src.getExtension()) - if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t2)); - for (org.hl7.fhir.r4.model.Extension t3 : src.getModifierExtension()) - if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t3)); - } - - static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguage(src.getLanguage()); - } - - static public org.hl7.fhir.r4.model.Enumeration convertPublicationStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertPublicationStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.CanonicalType convertReferenceToCanonical(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - org.hl7.fhir.r4.model.CanonicalType dst = new org.hl7.fhir.r4.model.CanonicalType(src.getReference()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.dstu3.model.Reference convertCanonicalToReference(org.hl7.fhir.r4.model.CanonicalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Reference dst = new org.hl7.fhir.dstu3.model.Reference(src.getValue()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertDocumentRelationshipType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case REPLACES: - tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.REPLACES); - break; - case TRANSFORMS: - tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.TRANSFORMS); - break; - case SIGNS: - tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.SIGNS); - break; - case APPENDS: - tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.APPENDS); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertDocumentRelationshipType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case REPLACES: - tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.REPLACES); - break; - case TRANSFORMS: - tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.TRANSFORMS); - break; - case SIGNS: - tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.SIGNS); - break; - case APPENDS: - tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.APPENDS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.Encounter.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasRole()) - tgt.setUse(convertCodeableConcept(src.getRole())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.Encounter.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasUse()) - tgt.setRole(convertCodeableConcept(src.getUse())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasRole()) - tgt.setRole(convertCodeableConcept(src.getRole())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasRole()) - tgt.setRole(convertCodeableConcept(src.getRole())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static final public String URN_IETF_RFC_3986 = "urn:ietf:rfc:3986"; - - public static String convertCoding2Uri(org.hl7.fhir.dstu3.model.Coding code) { - return code.getSystem() + "/" + code.getCode(); - } - - public static org.hl7.fhir.dstu3.model.Coding convertUri2Coding(String uri) { - int i = uri.lastIndexOf("/"); - return new org.hl7.fhir.dstu3.model.Coding().setSystem(uri.substring(0, i)).setCode(uri.substring(i + 1)); - } - - static public org.hl7.fhir.r4.model.Enumeration convertDaysOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeekEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertDaysOfWeek(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeekEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestReport.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertUri(src.getDetailElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertUri(src.getDetailElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertTestReportActionResult(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestReport.TestReportActionResultEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case PASS: - tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.PASS); - break; - case SKIP: - tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.SKIP); - break; - case FAIL: - tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.FAIL); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.WARNING); - break; - case ERROR: - tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.ERROR); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertTestReportActionResult(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestReport.TestReportActionResultEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case PASS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.PASS); - break; - case SKIP: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.SKIP); - break; - case FAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.FAIL); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.WARNING); - break; - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.ERROR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertString(src.getDetailElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertString(src.getDetailElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestReport.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestReport.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestReport.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestScript.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCoding(src.getType())); - if (src.hasResource()) - tgt.setResourceElement(convertCode(src.getResourceElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasAccept()) - tgt.setAccept(convertContentType(src.getAccept())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasDestination()) - tgt.setDestinationElement(convertInteger(src.getDestinationElement())); - if (src.hasEncodeRequestUrl()) - tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); - if (src.hasOrigin()) - tgt.setOriginElement(convertInteger(src.getOriginElement())); - if (src.hasParams()) - tgt.setParamsElement(convertString(src.getParamsElement())); - for (org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) - tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); - if (src.hasRequestId()) - tgt.setRequestIdElement(convertId(src.getRequestIdElement())); - if (src.hasResponseId()) - tgt.setResponseIdElement(convertId(src.getResponseIdElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasTargetId()) - tgt.setTargetId(src.getTargetId()); - if (src.hasUrl()) - tgt.setUrlElement(convertString(src.getUrlElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCoding(src.getType())); - if (src.hasResource()) - tgt.setResourceElement(convertCode(src.getResourceElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasAccept()) - tgt.setAccept(convertContentType(src.getAccept())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasDestination()) - tgt.setDestinationElement(convertInteger(src.getDestinationElement())); - if (src.hasEncodeRequestUrl()) - tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); - if (src.hasOrigin()) - tgt.setOriginElement(convertInteger(src.getOriginElement())); - if (src.hasParams()) - tgt.setParamsElement(convertString(src.getParamsElement())); - for (org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) - tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); - if (src.hasRequestId()) - tgt.setRequestIdElement(convertId(src.getRequestIdElement())); - if (src.hasResponseId()) - tgt.setResponseIdElement(convertId(src.getResponseIdElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasTargetId()) - tgt.setTargetId(src.getTargetId()); - if (src.hasUrl()) - tgt.setUrlElement(convertString(src.getUrlElement())); - return tgt; - } - - static public String convertContentType(org.hl7.fhir.dstu3.model.TestScript.ContentType src) throws FHIRException { - if (src == null) - return null; - switch (src) { - case XML: - return "application/fhir+xml"; - case JSON: - return "application/fhir+json"; - case TTL: - return "text/turtle"; - case NONE: - return null; - default: - return null; - } - } - - static public org.hl7.fhir.dstu3.model.TestScript.ContentType convertContentType(String src) throws FHIRException { - if (src == null) - return null; - if (src.contains("xml")) - return org.hl7.fhir.dstu3.model.TestScript.ContentType.XML; - if (src.contains("json")) - return org.hl7.fhir.dstu3.model.TestScript.ContentType.JSON; - if (src.contains("tu")) - return org.hl7.fhir.dstu3.model.TestScript.ContentType.TTL; - return org.hl7.fhir.dstu3.model.TestScript.ContentType.NONE; - } - - public static org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent(); - copyElement(src, tgt); - if (src.hasField()) - tgt.setFieldElement(convertString(src.getFieldElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent(); - copyElement(src, tgt); - if (src.hasField()) - tgt.setFieldElement(convertString(src.getFieldElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasDirection()) - tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); - if (src.hasCompareToSourceId()) - tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); - if (src.hasCompareToSourceExpression()) - tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); - if (src.hasCompareToSourcePath()) - tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasHeaderField()) - tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); - if (src.hasMinimumId()) - tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); - if (src.hasNavigationLinks()) - tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); - if (src.hasOperator()) - tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasRequestMethod()) - tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); - if (src.hasRequestURL()) - tgt.setRequestURLElement(convertString(src.getRequestURLElement())); - if (src.hasResource()) - tgt.setResourceElement(convertCode(src.getResourceElement())); - if (src.hasResponse()) - tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); - if (src.hasResponseCode()) - tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasValidateProfileId()) - tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasWarningOnly()) - tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasDirection()) - tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); - if (src.hasCompareToSourceId()) - tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); - if (src.hasCompareToSourceExpression()) - tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); - if (src.hasCompareToSourcePath()) - tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasHeaderField()) - tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); - if (src.hasMinimumId()) - tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); - if (src.hasNavigationLinks()) - tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); - if (src.hasOperator()) - tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasRequestMethod()) - tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); - if (src.hasRequestURL()) - tgt.setRequestURLElement(convertString(src.getRequestURLElement())); - if (src.hasResource()) - tgt.setResourceElement(convertCode(src.getResourceElement())); - if (src.hasResponse()) - tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); - if (src.hasResponseCode()) - tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasValidateProfileId()) - tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasWarningOnly()) - tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.AssertionDirectionTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case RESPONSE: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.RESPONSE); - break; - case REQUEST: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.REQUEST); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case RESPONSE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.RESPONSE); - break; - case REQUEST: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.REQUEST); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.AssertionOperatorTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case EQUALS: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EQUALS); - break; - case NOTEQUALS: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEQUALS); - break; - case IN: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTIN); - break; - case GREATERTHAN: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.GREATERTHAN); - break; - case LESSTHAN: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.LESSTHAN); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EMPTY); - break; - case NOTEMPTY: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEMPTY); - break; - case CONTAINS: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.CONTAINS); - break; - case NOTCONTAINS: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTCONTAINS); - break; - case EVAL: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EVAL); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorTypeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case EQUALS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EQUALS); - break; - case NOTEQUALS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEQUALS); - break; - case IN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTIN); - break; - case GREATERTHAN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.GREATERTHAN); - break; - case LESSTHAN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.LESSTHAN); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EMPTY); - break; - case NOTEMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEMPTY); - break; - case CONTAINS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.CONTAINS); - break; - case NOTCONTAINS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTCONTAINS); - break; - case EVAL: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EVAL); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case DELETE: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.DELETE); - break; - case GET: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.GET); - break; - case OPTIONS: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.OPTIONS); - break; - case PATCH: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.PATCH); - break; - case POST: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.POST); - break; - case PUT: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.PUT); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case DELETE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.DELETE); - break; - case GET: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.GET); - break; - case OPTIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.OPTIONS); - break; - case PATCH: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PATCH); - break; - case POST: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.POST); - break; - case PUT: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PUT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.AssertionResponseTypesEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case OKAY: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.OKAY); - break; - case CREATED: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CREATED); - break; - case NOCONTENT: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOCONTENT); - break; - case NOTMODIFIED: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTMODIFIED); - break; - case BAD: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.BAD); - break; - case FORBIDDEN: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.FORBIDDEN); - break; - case NOTFOUND: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTFOUND); - break; - case METHODNOTALLOWED: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); - break; - case CONFLICT: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CONFLICT); - break; - case GONE: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.GONE); - break; - case PRECONDITIONFAILED: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); - break; - case UNPROCESSABLE: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypesEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case OKAY: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.OKAY); - break; - case CREATED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CREATED); - break; - case NOCONTENT: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOCONTENT); - break; - case NOTMODIFIED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTMODIFIED); - break; - case BAD: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.BAD); - break; - case FORBIDDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.FORBIDDEN); - break; - case NOTFOUND: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTFOUND); - break; - case METHODNOTALLOWED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); - break; - case CONFLICT: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CONFLICT); - break; - case GONE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.GONE); - break; - case PRECONDITIONFAILED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); - break; - case UNPROCESSABLE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestScript.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestScript.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestScript.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertFilterOperator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ValueSet.FilterOperatorEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL); - break; - case ISA: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA); - break; - case DESCENDENTOF: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.DESCENDENTOF); - break; - case ISNOTA: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA); - break; - case REGEX: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX); - break; - case IN: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN); - break; - case GENERALIZES: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.GENERALIZES); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EXISTS); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertFilterOperator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ValueSet.FilterOperatorEnumFactory()); - VersionConvertor_30_40.copyElement(src, tgt); - switch (src.getValue()) { - case EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EQUAL); - break; - case ISA: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISA); - break; - case DESCENDENTOF: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.DESCENDENTOF); - break; - case ISNOTA: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISNOTA); - break; - case REGEX: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.REGEX); - break; - case IN: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NOTIN); - break; - case GENERALIZES: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.GENERALIZES); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EXISTS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, boolean nullOk) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Parameters) - return Parameters30_40.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu3.model.Account) - return Account30_40.convertAccount((org.hl7.fhir.dstu3.model.Account) src); - if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition) - return ActivityDefinition30_40.convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance) - return AllergyIntolerance30_40.convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Appointment) - return Appointment30_40.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); - if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) - return AppointmentResponse30_40.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) - return AuditEvent30_40.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.dstu3.model.Basic) - return Basic30_40.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); - if (src instanceof org.hl7.fhir.dstu3.model.Binary) - return Binary30_40.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); - if (src instanceof org.hl7.fhir.dstu3.model.BodySite) - return BodySite30_40.convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src); - if (src instanceof org.hl7.fhir.dstu3.model.Bundle) - return Bundle30_40.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) - return CapabilityStatement30_40.convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) - return CarePlan30_40.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); - if (src instanceof org.hl7.fhir.dstu3.model.CareTeam) - return CareTeam30_40.convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src); - if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) - return ClinicalImpression30_40.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) - return CodeSystem30_40.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.Communication) - return Communication30_40.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); - if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) - return CompartmentDefinition30_40.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Composition) - return Composition30_40.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); - if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) - return ConceptMap30_40.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu3.model.Condition) - return Condition30_40.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Consent) - return Consent30_40.convertConsent((org.hl7.fhir.dstu3.model.Consent) src); - if (src instanceof org.hl7.fhir.dstu3.model.Coverage) - return Coverage30_40.convertCoverage((org.hl7.fhir.dstu3.model.Coverage) src); - if (src instanceof org.hl7.fhir.dstu3.model.DataElement) - return DataElement30_40.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) - return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) - return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) - return DiagnosticReport30_40.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) - return DocumentReference30_40.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.dstu3.model.Encounter) - return Encounter30_40.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); - if (src instanceof org.hl7.fhir.dstu3.model.Endpoint) - return Endpoint30_40.convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src); - if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) - return EpisodeOfCare30_40.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile) - return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src); - if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) - return FamilyMemberHistory30_40.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.dstu3.model.Flag) - return Flag30_40.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); - if (src instanceof org.hl7.fhir.dstu3.model.Goal) - return Goal30_40.convertGoal((org.hl7.fhir.dstu3.model.Goal) src); - if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition) - return GraphDefinition30_40.convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Group) - return Group30_40.convertGroup((org.hl7.fhir.dstu3.model.Group) src); - if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) - return HealthcareService30_40.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) - return ImagingStudy30_40.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.dstu3.model.Immunization) - return Immunization30_40.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) - return ImplementationGuide30_40.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu3.model.Library) - return Library30_40.convertLibrary((org.hl7.fhir.dstu3.model.Library) src); - if (src instanceof org.hl7.fhir.dstu3.model.Linkage) - return Linkage30_40.convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src); - if (src instanceof org.hl7.fhir.dstu3.model.ListResource) - return List30_40.convertList((org.hl7.fhir.dstu3.model.ListResource) src); - if (src instanceof org.hl7.fhir.dstu3.model.Location) - return Location30_40.convertLocation((org.hl7.fhir.dstu3.model.Location) src); - if (src instanceof org.hl7.fhir.dstu3.model.Media) - return Media30_40.convertMedia((org.hl7.fhir.dstu3.model.Media) src); - if (src instanceof org.hl7.fhir.dstu3.model.Medication) - return Medication30_40.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration) - return MedicationAdministration30_40.convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) - return MedicationDispense30_40.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest) - return MedicationRequest30_40.convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) - return MedicationStatement30_40.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition) - return MessageDefinition30_40.convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) - return MessageHeader30_40.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) - return NamingSystem30_40.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.Observation) - return Observation30_40.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) - return OperationDefinition30_40.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) - return OperationOutcome30_40.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu3.model.Organization) - return Organization30_40.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); - if (src instanceof org.hl7.fhir.dstu3.model.Patient) - return Patient30_40.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); - if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice) - return PaymentNotice30_40.convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src); - if (src instanceof org.hl7.fhir.dstu3.model.Person) - return Person30_40.convertPerson((org.hl7.fhir.dstu3.model.Person) src); - if (src instanceof org.hl7.fhir.dstu3.model.PlanDefinition) - return PlanDefinition30_40.convertPlanDefinition((org.hl7.fhir.dstu3.model.PlanDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) - return Practitioner30_40.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); - if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole) - return PractitionerRole30_40.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src); - if (src instanceof org.hl7.fhir.dstu3.model.Procedure) - return Procedure30_40.convertProcedure((org.hl7.fhir.dstu3.model.Procedure) src); - if (src instanceof org.hl7.fhir.dstu3.model.ProcedureRequest) - return ProcedureRequest30_40.convertProcedureRequest((org.hl7.fhir.dstu3.model.ProcedureRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.Provenance) - return Provenance30_40.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) - return Questionnaire30_40.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) - return QuestionnaireResponse30_40.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) - return RelatedPerson30_40.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) - return RiskAssessment30_40.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.dstu3.model.Schedule) - return Schedule30_40.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); - if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) - return SearchParameter30_40.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu3.model.Sequence) - return Sequence30_40.convertSequence((org.hl7.fhir.dstu3.model.Sequence) src); - if (src instanceof org.hl7.fhir.dstu3.model.Slot) - return Slot30_40.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); - if (src instanceof org.hl7.fhir.dstu3.model.Specimen) - return Specimen30_40.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); - if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) - return StructureDefinition30_40.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.StructureMap) - return StructureMap30_40.convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src); - if (src instanceof org.hl7.fhir.dstu3.model.Subscription) - return Subscription30_40.convertSubscription((org.hl7.fhir.dstu3.model.Subscription) src); - if (src instanceof org.hl7.fhir.dstu3.model.Substance) - return Substance30_40.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); - if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) - return SupplyDelivery30_40.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.dstu3.model.TestReport) - return TestReport30_40.convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src); - if (src instanceof org.hl7.fhir.dstu3.model.TestScript) - return TestScript30_40.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) - return ValueSet30_40.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); - if (!nullOk) - throw new FHIRException("Unknown resource " + src.fhirType()); - else - return null; - } - - public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, boolean nullOk) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r4.model.Parameters) { - if (((org.hl7.fhir.r4.model.Parameters) src).hasParameter("profile-url")) - return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.r4.model.Parameters) src); - else - return Parameters30_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); - } - if (src instanceof org.hl7.fhir.r4.model.Account) - return Account30_40.convertAccount((org.hl7.fhir.r4.model.Account) src); - if (src instanceof org.hl7.fhir.r4.model.ActivityDefinition) - return ActivityDefinition30_40.convertActivityDefinition((org.hl7.fhir.r4.model.ActivityDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.AllergyIntolerance) - return AllergyIntolerance30_40.convertAllergyIntolerance((org.hl7.fhir.r4.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.r4.model.Appointment) - return Appointment30_40.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); - if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) - return AppointmentResponse30_40.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.r4.model.AuditEvent) - return AuditEvent30_40.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.r4.model.Basic) - return Basic30_40.convertBasic((org.hl7.fhir.r4.model.Basic) src); - if (src instanceof org.hl7.fhir.r4.model.Binary) - return Binary30_40.convertBinary((org.hl7.fhir.r4.model.Binary) src); - if (src instanceof org.hl7.fhir.r4.model.BodyStructure) - return BodySite30_40.convertBodySite((org.hl7.fhir.r4.model.BodyStructure) src); - if (src instanceof org.hl7.fhir.r4.model.Bundle) - return Bundle30_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src); - if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) - return CapabilityStatement30_40.convertCapabilityStatement((org.hl7.fhir.r4.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r4.model.CarePlan) - return CarePlan30_40.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); - if (src instanceof org.hl7.fhir.r4.model.CareTeam) - return CareTeam30_40.convertCareTeam((org.hl7.fhir.r4.model.CareTeam) src); - if (src instanceof org.hl7.fhir.r4.model.ClinicalImpression) - return ClinicalImpression30_40.convertClinicalImpression((org.hl7.fhir.r4.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.r4.model.CodeSystem) - return CodeSystem30_40.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.r4.model.Communication) - return Communication30_40.convertCommunication((org.hl7.fhir.r4.model.Communication) src); - if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) - return CompartmentDefinition30_40.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Composition) - return Composition30_40.convertComposition((org.hl7.fhir.r4.model.Composition) src); - if (src instanceof org.hl7.fhir.r4.model.ConceptMap) - return ConceptMap30_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r4.model.Condition) - return Condition30_40.convertCondition((org.hl7.fhir.r4.model.Condition) src); - if (src instanceof org.hl7.fhir.r4.model.Consent) - return Consent30_40.convertConsent((org.hl7.fhir.r4.model.Consent) src); - if (src instanceof org.hl7.fhir.r4.model.Coverage) - return Coverage30_40.convertCoverage((org.hl7.fhir.r4.model.Coverage) src); - if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) - return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.r4.model.Device) - return Device30_40.convertDevice((org.hl7.fhir.r4.model.Device) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) - return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) - return DiagnosticReport30_40.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.r4.model.DocumentReference) - return DocumentReference30_40.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r4.model.Encounter) - return Encounter30_40.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); - if (src instanceof org.hl7.fhir.r4.model.Endpoint) - return Endpoint30_40.convertEndpoint((org.hl7.fhir.r4.model.Endpoint) src); - if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) - return EpisodeOfCare30_40.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) - return FamilyMemberHistory30_40.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.r4.model.Flag) - return Flag30_40.convertFlag((org.hl7.fhir.r4.model.Flag) src); - if (src instanceof org.hl7.fhir.r4.model.Goal) - return Goal30_40.convertGoal((org.hl7.fhir.r4.model.Goal) src); - if (src instanceof org.hl7.fhir.r4.model.GraphDefinition) - return GraphDefinition30_40.convertGraphDefinition((org.hl7.fhir.r4.model.GraphDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Group) - return Group30_40.convertGroup((org.hl7.fhir.r4.model.Group) src); - if (src instanceof org.hl7.fhir.r4.model.HealthcareService) - return HealthcareService30_40.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.r4.model.ImagingStudy) - return ImagingStudy30_40.convertImagingStudy((org.hl7.fhir.r4.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.r4.model.Immunization) - return Immunization30_40.convertImmunization((org.hl7.fhir.r4.model.Immunization) src); - if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) - return ImplementationGuide30_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r4.model.Library) - return Library30_40.convertLibrary((org.hl7.fhir.r4.model.Library) src); - if (src instanceof org.hl7.fhir.r4.model.Linkage) - return Linkage30_40.convertLinkage((org.hl7.fhir.r4.model.Linkage) src); - if (src instanceof org.hl7.fhir.r4.model.ListResource) - return List30_40.convertList((org.hl7.fhir.r4.model.ListResource) src); - if (src instanceof org.hl7.fhir.r4.model.Location) - return Location30_40.convertLocation((org.hl7.fhir.r4.model.Location) src); - if (src instanceof org.hl7.fhir.r4.model.Media) - return Media30_40.convertMedia((org.hl7.fhir.r4.model.Media) src); - if (src instanceof org.hl7.fhir.r4.model.Medication) - return Medication30_40.convertMedication((org.hl7.fhir.r4.model.Medication) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationAdministration) - return MedicationAdministration30_40.convertMedicationAdministration((org.hl7.fhir.r4.model.MedicationAdministration) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) - return MedicationDispense30_40.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationRequest) - return MedicationRequest30_40.convertMedicationRequest((org.hl7.fhir.r4.model.MedicationRequest) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) - return MedicationStatement30_40.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.r4.model.MessageDefinition) - return MessageDefinition30_40.convertMessageDefinition((org.hl7.fhir.r4.model.MessageDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.MessageHeader) - return MessageHeader30_40.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.r4.model.NamingSystem) - return NamingSystem30_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r4.model.Observation) - return Observation30_40.convertObservation((org.hl7.fhir.r4.model.Observation) src); - if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) - return OperationDefinition30_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) - return OperationOutcome30_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r4.model.Organization) - return Organization30_40.convertOrganization((org.hl7.fhir.r4.model.Organization) src); - if (src instanceof org.hl7.fhir.r4.model.Patient) - return Patient30_40.convertPatient((org.hl7.fhir.r4.model.Patient) src); - if (src instanceof org.hl7.fhir.r4.model.PaymentNotice) - return PaymentNotice30_40.convertPaymentNotice((org.hl7.fhir.r4.model.PaymentNotice) src); - if (src instanceof org.hl7.fhir.r4.model.Person) - return Person30_40.convertPerson((org.hl7.fhir.r4.model.Person) src); - if (src instanceof org.hl7.fhir.r4.model.PlanDefinition) - return PlanDefinition30_40.convertPlanDefinition((org.hl7.fhir.r4.model.PlanDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Practitioner) - return Practitioner30_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); - if (src instanceof org.hl7.fhir.r4.model.PractitionerRole) - return PractitionerRole30_40.convertPractitionerRole((org.hl7.fhir.r4.model.PractitionerRole) src); - if (src instanceof org.hl7.fhir.r4.model.Procedure) - return Procedure30_40.convertProcedure((org.hl7.fhir.r4.model.Procedure) src); - if (src instanceof org.hl7.fhir.r4.model.ServiceRequest) - return ProcedureRequest30_40.convertProcedureRequest((org.hl7.fhir.r4.model.ServiceRequest) src); - if (src instanceof org.hl7.fhir.r4.model.Provenance) - return Provenance30_40.convertProvenance((org.hl7.fhir.r4.model.Provenance) src); - if (src instanceof org.hl7.fhir.r4.model.Questionnaire) - return Questionnaire30_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) - return QuestionnaireResponse30_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r4.model.RelatedPerson) - return RelatedPerson30_40.convertRelatedPerson((org.hl7.fhir.r4.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) - return RiskAssessment30_40.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.r4.model.Schedule) - return Schedule30_40.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); - if (src instanceof org.hl7.fhir.r4.model.SearchParameter) - return SearchParameter30_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r4.model.MolecularSequence) - return Sequence30_40.convertSequence((org.hl7.fhir.r4.model.MolecularSequence) src); - if (src instanceof org.hl7.fhir.r4.model.Slot) - return Slot30_40.convertSlot((org.hl7.fhir.r4.model.Slot) src); - if (src instanceof org.hl7.fhir.r4.model.Specimen) - return Specimen30_40.convertSpecimen((org.hl7.fhir.r4.model.Specimen) src); - if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) - return StructureDefinition30_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.StructureMap) - return StructureMap30_40.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); - if (src instanceof org.hl7.fhir.r4.model.Subscription) - return Subscription30_40.convertSubscription((org.hl7.fhir.r4.model.Subscription) src); - if (src instanceof org.hl7.fhir.r4.model.Substance) - return Substance30_40.convertSubstance((org.hl7.fhir.r4.model.Substance) src); - if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) - return SupplyDelivery30_40.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.r4.model.TestReport) - return TestReport30_40.convertTestReport((org.hl7.fhir.r4.model.TestReport) src); - if (src instanceof org.hl7.fhir.r4.model.TestScript) - return TestScript30_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); - if (src instanceof org.hl7.fhir.r4.model.ValueSet) - return ValueSet30_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); - if (!nullOk) - throw new FHIRException("Unknown resource " + src.fhirType()); - else - return null; - } - - public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src, boolean b) { - TerminologyCapabilities res = new TerminologyCapabilities(); - for (ParametersParameterComponent p : src.getParameter()) { - if (p.getName().equals("system")) - res.addCodeSystem().setUri(p.getValue().primitiveValue()); - } - return res; - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "ActivityDefinition", "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodyStructure", "Bundle", "CapabilityStatement", "CarePlan", "CareTeam", "ClinicalImpression", "CodeSystem", "Communication", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Consent", "DetectedIssue", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "Endpoint", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Goal", "GraphDefinition", "Group", "HealthcareService", "ImagingStudy", "Immunization", "ImplementationGuide", "Library", "Linkage", "ListResource", "Location", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationRequest", "MedicationStatement", "MessageDefinition", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "PaymentNotice", "Person", "PlanDefinition", "Practitioner", "PractitionerRole", "Procedure", "ProcedureRequest", "ProcessRequest", "Provenance", "Questionnaire", "QuestionnaireResponse", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "Slot", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "TestReport", "TestScript", "ValueSet"); - } + } else { + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentity()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMap()) tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasComment()) tgt.setCommentElement(convertString(src.getCommentElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentity()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMap()) tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasComment()) tgt.setCommentElement(convertString(src.getCommentElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.setFamilyElement(convertString(src.getFamilyElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.setFamilyElement(convertString(src.getFamilyElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.dstu3.model.ParameterDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ParameterDefinition tgt = new org.hl7.fhir.r4.model.ParameterDefinition(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertCode(src.getNameElement())); + if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); + if (src.hasMin()) tgt.setMinElement(convertInteger(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasDocumentation()) tgt.setDocumentationElement(convertString(src.getDocumentationElement())); + if (src.hasType()) tgt.setTypeElement(convertCode(src.getTypeElement())); + if (src.hasProfile()) { + tgt.setProfile(convertReference(src.getProfile()).getReference()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ParameterDefinition tgt = new org.hl7.fhir.dstu3.model.ParameterDefinition(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertCode(src.getNameElement())); + if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); + if (src.hasMin()) tgt.setMinElement(convertInteger(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasDocumentation()) tgt.setDocumentationElement(convertString(src.getDocumentationElement())); + if (src.hasType()) tgt.setTypeElement(convertCode(src.getTypeElement())); + if (src.hasProfile()) tgt.setProfile(new org.hl7.fhir.dstu3.model.Reference(src.getProfile())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertParameterUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ParameterDefinition.ParameterUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL); + } else { + switch (src.getValue()) { + case IN: + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.IN); + break; + case OUT: + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.OUT); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertParameterUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUseEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL); + } else { + switch (src.getValue()) { + case IN: + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.IN); + break; + case OUT: + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.OUT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.RelatedArtifact tgt = new org.hl7.fhir.r4.model.RelatedArtifact(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasCitation()) tgt.setCitation(src.getCitation()); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasDocument()) tgt.setDocument(convertAttachment(src.getDocument())); + if (src.hasResource()) tgt.setResourceElement(convertReferenceToCanonical(src.getResource())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.RelatedArtifact tgt = new org.hl7.fhir.dstu3.model.RelatedArtifact(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasCitation()) tgt.setCitation(src.getCitation()); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasDocument()) tgt.setDocument(convertAttachment(src.getDocument())); + if (src.hasResource()) tgt.setResource(convertCanonicalToReference(src.getResourceElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL); + } else { + switch (src.getValue()) { + case DOCUMENTATION: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); + break; + case JUSTIFICATION: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); + break; + case CITATION: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.CITATION); + break; + case PREDECESSOR: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); + break; + case SUCCESSOR: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); + break; + case DERIVEDFROM: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); + break; + case DEPENDSON: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + break; + case COMPOSEDOF: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); + } else { + switch (src.getValue()) { + case DOCUMENTATION: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); + break; + case JUSTIFICATION: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); + break; + case CITATION: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.CITATION); + break; + case PREDECESSOR: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); + break; + case SUCCESSOR: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); + break; + case DERIVEDFROM: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); + break; + case DEPENDSON: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + break; + case COMPOSEDOF: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) + tgt.addEventElement().setValueAsString(t.getValueAsString()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) + tgt.addEventElement().setValueAsString(t.getValueAsString()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_40::convertDayOfWeek).collect(Collectors.toList())); + for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); + tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList())); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_40::convertDayOfWeek).collect(Collectors.toList())); + for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); + tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList())); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertDayOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.DayOfWeekEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertDayOfWeek(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.DayOfWeekEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case MORN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN); + break; + case AFT: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT); + break; + case EVE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE); + break; + case NIGHT: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NIGHT); + break; + case PHS: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PHS); + break; + case HS: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case MORN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.MORN); + break; + case AFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AFT); + break; + case EVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.EVE); + break; + case NIGHT: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NIGHT); + break; + case PHS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PHS); + break; + case HS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.UsageContext convertUsageContext(org.hl7.fhir.dstu3.model.UsageContext src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.UsageContext tgt = new org.hl7.fhir.r4.model.UsageContext(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(convertCoding(src.getCode())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UsageContext convertUsageContext(org.hl7.fhir.r4.model.UsageContext src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.UsageContext tgt = new org.hl7.fhir.dstu3.model.UsageContext(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(convertCoding(src.getCode())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.SimpleQuantity tgt = new org.hl7.fhir.r4.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.dstu3.model.TriggerDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TriggerDefinition tgt = new org.hl7.fhir.r4.model.TriggerDefinition(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertTriggerType(src.getTypeElement())); + if (src.hasEventName()) tgt.setNameElement(convertString(src.getEventNameElement())); + if (src.hasEventTiming()) tgt.setTiming(convertType(src.getEventTiming())); + if (src.hasEventData()) tgt.addData(convertDataRequirement(src.getEventData())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r4.model.TriggerDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TriggerDefinition tgt = new org.hl7.fhir.dstu3.model.TriggerDefinition(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertTriggerType(src.getTypeElement())); + if (src.hasName()) tgt.setEventNameElement(convertString(src.getNameElement())); + if (src.hasTiming()) tgt.setEventTiming(convertType(src.getTiming())); + if (src.hasData()) tgt.setEventData(convertDataRequirement(src.getDataFirstRep())); + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement convertDataRequirement(org.hl7.fhir.dstu3.model.DataRequirement src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement tgt = new org.hl7.fhir.r4.model.DataRequirement(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertCode(src.getTypeElement())); + for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); + for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) + tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); + for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) + tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DataRequirement convertDataRequirement(org.hl7.fhir.r4.model.DataRequirement src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DataRequirement tgt = new org.hl7.fhir.dstu3.model.DataRequirement(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertCode(src.getTypeElement())); + for (org.hl7.fhir.r4.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r4.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); + for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) + tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); + for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) + tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValueSet()) { + Type t = convertType(src.getValueSet()); + if (t instanceof org.hl7.fhir.r4.model.Reference) + tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); + else tgt.setValueSet(t.primitiveValue()); + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + for (org.hl7.fhir.dstu3.model.CodeType t : src.getValueCode()) tgt.addCode(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.Coding t : src.getValueCoding()) tgt.addCode(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getValueCodeableConcept()) tgt.addCode(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValueSet()) { + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); + } + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) { + tgt.addValueCoding(convertCoding(t)); + } + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertTriggerType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TriggerDefinition.TriggerTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NULL); + } else { + switch (src.getValue()) { + case NAMEDEVENT: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NAMEDEVENT); + break; + case PERIODIC: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.PERIODIC); + break; + case DATAADDED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAADDED); + break; + case DATAMODIFIED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAMODIFIED); + break; + case DATAREMOVED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAREMOVED); + break; + case DATAACCESSED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSED); + break; + case DATAACCESSENDED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSENDED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertTriggerType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NULL); + } else { + switch (src.getValue()) { + case NAMEDEVENT: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NAMEDEVENT); + break; + case PERIODIC: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.PERIODIC); + break; + case DATAADDED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAADDED); + break; + case DATAMODIFIED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAMODIFIED); + break; + case DATAREMOVED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAREMOVED); + break; + case DATAACCESSED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSED); + break; + case DATAACCESSENDED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSENDED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeType) return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateType) return convertDate((org.hl7.fhir.dstu3.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IdType) return convertId((org.hl7.fhir.dstu3.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu3.model.InstantType) + return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu3.model.OidType) return convertOid((org.hl7.fhir.dstu3.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.StringType) + return convertString((org.hl7.fhir.dstu3.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu3.model.TimeType) return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UuidType) return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UriType) return convertUri((org.hl7.fhir.dstu3.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu3.model.Extension) + return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu3.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu3.model.Age) return convertAge((org.hl7.fhir.dstu3.model.Age) src); + if (src instanceof org.hl7.fhir.dstu3.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu3.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu3.model.Coding) return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu3.model.Count) return convertCount((org.hl7.fhir.dstu3.model.Count) src); + if (src instanceof org.hl7.fhir.dstu3.model.Distance) + return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Duration) + return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu3.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu3.model.Money) return convertMoney((org.hl7.fhir.dstu3.model.Money) src); + if (src instanceof org.hl7.fhir.dstu3.model.Period) return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); + if (src instanceof org.hl7.fhir.dstu3.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.dstu3.model.SimpleQuantity) src); + if (src instanceof org.hl7.fhir.dstu3.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu3.model.Range) return convertRange((org.hl7.fhir.dstu3.model.Range) src); + if (src instanceof org.hl7.fhir.dstu3.model.Ratio) return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu3.model.Reference) + return convertReference((org.hl7.fhir.dstu3.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu3.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu3.model.Signature) + return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu3.model.Address) return convertAddress((org.hl7.fhir.dstu3.model.Address) src); + if (src instanceof org.hl7.fhir.dstu3.model.ContactDetail) + return convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) src); + if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu3.model.Contributor) + return convertContributor((org.hl7.fhir.dstu3.model.Contributor) src); + if (src instanceof org.hl7.fhir.dstu3.model.Dosage) return convertDosage((org.hl7.fhir.dstu3.model.Dosage) src); + if (src instanceof org.hl7.fhir.dstu3.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu3.model.Meta) return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu3.model.ParameterDefinition) + return convertParameterDefinition((org.hl7.fhir.dstu3.model.ParameterDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.RelatedArtifact) + return convertRelatedArtifact((org.hl7.fhir.dstu3.model.RelatedArtifact) src); + if (src instanceof org.hl7.fhir.dstu3.model.Timing) return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); + if (src instanceof org.hl7.fhir.dstu3.model.UsageContext) + return convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) src); + if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.DataRequirement) + return convertDataRequirement((org.hl7.fhir.dstu3.model.DataRequirement) src); + if (src instanceof org.hl7.fhir.dstu3.model.TriggerDefinition) + return convertTriggerDefinition((org.hl7.fhir.dstu3.model.TriggerDefinition) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r4.model.BooleanType) + return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r4.model.CodeType) return convertCode((org.hl7.fhir.r4.model.CodeType) src); + if (src instanceof org.hl7.fhir.r4.model.DateType) return convertDate((org.hl7.fhir.r4.model.DateType) src); + if (src instanceof org.hl7.fhir.r4.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r4.model.DecimalType) + return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r4.model.IdType) return convertId((org.hl7.fhir.r4.model.IdType) src); + if (src instanceof org.hl7.fhir.r4.model.InstantType) + return convertInstant((org.hl7.fhir.r4.model.InstantType) src); + if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r4.model.IntegerType) + return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r4.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r4.model.OidType) return convertOid((org.hl7.fhir.r4.model.OidType) src); + if (src instanceof org.hl7.fhir.r4.model.StringType) return convertString((org.hl7.fhir.r4.model.StringType) src); + if (src instanceof org.hl7.fhir.r4.model.TimeType) return convertTime((org.hl7.fhir.r4.model.TimeType) src); + if (src instanceof org.hl7.fhir.r4.model.UuidType) return convertUuid((org.hl7.fhir.r4.model.UuidType) src); + if (src instanceof org.hl7.fhir.r4.model.UriType) return convertUri((org.hl7.fhir.r4.model.UriType) src); + if (src instanceof org.hl7.fhir.r4.model.Extension) return convertExtension((org.hl7.fhir.r4.model.Extension) src); + if (src instanceof org.hl7.fhir.r4.model.Narrative) return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); + if (src instanceof org.hl7.fhir.r4.model.Age) return convertAge((org.hl7.fhir.r4.model.Age) src); + if (src instanceof org.hl7.fhir.r4.model.Annotation) + return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); + if (src instanceof org.hl7.fhir.r4.model.Attachment) + return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); + if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r4.model.Coding) return convertCoding((org.hl7.fhir.r4.model.Coding) src); + if (src instanceof org.hl7.fhir.r4.model.Count) return convertCount((org.hl7.fhir.r4.model.Count) src); + if (src instanceof org.hl7.fhir.r4.model.Distance) return convertDistance((org.hl7.fhir.r4.model.Distance) src); + if (src instanceof org.hl7.fhir.r4.model.Duration) return convertDuration((org.hl7.fhir.r4.model.Duration) src); + if (src instanceof org.hl7.fhir.r4.model.Identifier) + return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); + if (src instanceof org.hl7.fhir.r4.model.Money) return convertMoney((org.hl7.fhir.r4.model.Money) src); + if (src instanceof org.hl7.fhir.r4.model.Period) return convertPeriod((org.hl7.fhir.r4.model.Period) src); + if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); + if (src instanceof org.hl7.fhir.r4.model.Quantity) return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); + if (src instanceof org.hl7.fhir.r4.model.Range) return convertRange((org.hl7.fhir.r4.model.Range) src); + if (src instanceof org.hl7.fhir.r4.model.Ratio) return convertRatio((org.hl7.fhir.r4.model.Ratio) src); + if (src instanceof org.hl7.fhir.r4.model.Reference) return convertReference((org.hl7.fhir.r4.model.Reference) src); + if (src instanceof org.hl7.fhir.r4.model.SampledData) + return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); + if (src instanceof org.hl7.fhir.r4.model.Signature) return convertSignature((org.hl7.fhir.r4.model.Signature) src); + if (src instanceof org.hl7.fhir.r4.model.Address) return convertAddress((org.hl7.fhir.r4.model.Address) src); + if (src instanceof org.hl7.fhir.r4.model.ContactDetail) + return convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) src); + if (src instanceof org.hl7.fhir.r4.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r4.model.Contributor) + return convertContributor((org.hl7.fhir.r4.model.Contributor) src); + if (src instanceof org.hl7.fhir.r4.model.Dosage) return convertDosage((org.hl7.fhir.r4.model.Dosage) src); + if (src instanceof org.hl7.fhir.r4.model.HumanName) return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); + if (src instanceof org.hl7.fhir.r4.model.Meta) return convertMeta((org.hl7.fhir.r4.model.Meta) src); + if (src instanceof org.hl7.fhir.r4.model.ParameterDefinition) + return convertParameterDefinition((org.hl7.fhir.r4.model.ParameterDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.RelatedArtifact) + return convertRelatedArtifact((org.hl7.fhir.r4.model.RelatedArtifact) src); + if (src instanceof org.hl7.fhir.r4.model.Timing) return convertTiming((org.hl7.fhir.r4.model.Timing) src); + if (src instanceof org.hl7.fhir.r4.model.UsageContext) + return convertUsageContext((org.hl7.fhir.r4.model.UsageContext) src); + if (src instanceof org.hl7.fhir.r4.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.DataRequirement) + return convertDataRequirement((org.hl7.fhir.r4.model.DataRequirement) src); + if (src instanceof org.hl7.fhir.r4.model.TriggerDefinition) + return convertTriggerDefinition((org.hl7.fhir.r4.model.TriggerDefinition) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; + } + + static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); + for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) + if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); + for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) + if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); + } + + static public void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r4.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); + for (org.hl7.fhir.r4.model.Extension t2 : src.getExtension()) + if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); + for (org.hl7.fhir.r4.model.Extension t3 : src.getModifierExtension()) + if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); + } + + static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); + } + + static public org.hl7.fhir.r4.model.Enumeration convertPublicationStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.RETIRED); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertPublicationStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.CanonicalType convertReferenceToCanonical(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { + org.hl7.fhir.r4.model.CanonicalType dst = new org.hl7.fhir.r4.model.CanonicalType(src.getReference()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.dstu3.model.Reference convertCanonicalToReference(org.hl7.fhir.r4.model.CanonicalType src) throws FHIRException { + org.hl7.fhir.dstu3.model.Reference dst = new org.hl7.fhir.dstu3.model.Reference(src.getValue()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r4.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertDocumentRelationshipType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.NULL); + } else { + switch (src.getValue()) { + case REPLACES: + tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.REPLACES); + break; + case TRANSFORMS: + tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.TRANSFORMS); + break; + case SIGNS: + tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.SIGNS); + break; + case APPENDS: + tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.APPENDS); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.DocumentReference.DocumentRelationshipType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertDocumentRelationshipType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.NULL); + } else { + switch (src.getValue()) { + case REPLACES: + tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.REPLACES); + break; + case TRANSFORMS: + tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.TRANSFORMS); + break; + case SIGNS: + tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.SIGNS); + break; + case APPENDS: + tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.APPENDS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.DocumentReference.DocumentRelationshipType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.Encounter.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasRole()) tgt.setUse(convertCodeableConcept(src.getRole())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.Encounter.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasUse()) tgt.setRole(convertCodeableConcept(src.getUse())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasRole()) tgt.setRole(convertCodeableConcept(src.getRole())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasRole()) tgt.setRole(convertCodeableConcept(src.getRole())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static final public String URN_IETF_RFC_3986 = "urn:ietf:rfc:3986"; + + public static String convertCoding2Uri(org.hl7.fhir.dstu3.model.Coding code) { + return code.getSystem() + "/" + code.getCode(); + } + + public static org.hl7.fhir.dstu3.model.Coding convertUri2Coding(String uri) { + int i = uri.lastIndexOf("/"); + return new org.hl7.fhir.dstu3.model.Coding().setSystem(uri.substring(0, i)).setCode(uri.substring(i + 1)); + } + + static public org.hl7.fhir.r4.model.Enumeration convertDaysOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeekEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.PractitionerRole.DaysOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertDaysOfWeek(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeekEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.PractitionerRole.DaysOfWeek.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestReport.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertUri(src.getDetailElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestReport.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertUri(src.getDetailElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertTestReportActionResult(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestReport.TestReportActionResultEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.NULL); + } else { + switch (src.getValue()) { + case PASS: + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.PASS); + break; + case SKIP: + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.SKIP); + break; + case FAIL: + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.FAIL); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.WARNING); + break; + case ERROR: + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.ERROR); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TestReport.TestReportActionResult.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertTestReportActionResult(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestReport.TestReportActionResultEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL); + } else { + switch (src.getValue()) { + case PASS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.PASS); + break; + case SKIP: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.SKIP); + break; + case FAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.FAIL); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.WARNING); + break; + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.ERROR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertString(src.getDetailElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestReport.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertString(src.getDetailElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestReport.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestReport.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestReport.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestReport.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r4.model.TestScript.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(convertCoding(src.getType())); + if (src.hasResource()) tgt.setResourceElement(convertCode(src.getResourceElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasAccept()) tgt.setAccept(convertContentType(src.getAccept())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasDestination()) tgt.setDestinationElement(convertInteger(src.getDestinationElement())); + if (src.hasEncodeRequestUrl()) tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); + if (src.hasOrigin()) tgt.setOriginElement(convertInteger(src.getOriginElement())); + if (src.hasParams()) tgt.setParamsElement(convertString(src.getParamsElement())); + for (org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) + tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); + if (src.hasRequestId()) tgt.setRequestIdElement(convertId(src.getRequestIdElement())); + if (src.hasResponseId()) tgt.setResponseIdElement(convertId(src.getResponseIdElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasTargetId()) tgt.setTargetId(src.getTargetId()); + if (src.hasUrl()) tgt.setUrlElement(convertString(src.getUrlElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(convertCoding(src.getType())); + if (src.hasResource()) tgt.setResourceElement(convertCode(src.getResourceElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasAccept()) tgt.setAccept(convertContentType(src.getAccept())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasDestination()) tgt.setDestinationElement(convertInteger(src.getDestinationElement())); + if (src.hasEncodeRequestUrl()) tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); + if (src.hasOrigin()) tgt.setOriginElement(convertInteger(src.getOriginElement())); + if (src.hasParams()) tgt.setParamsElement(convertString(src.getParamsElement())); + for (org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) + tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); + if (src.hasRequestId()) tgt.setRequestIdElement(convertId(src.getRequestIdElement())); + if (src.hasResponseId()) tgt.setResponseIdElement(convertId(src.getResponseIdElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasTargetId()) tgt.setTargetId(src.getTargetId()); + if (src.hasUrl()) tgt.setUrlElement(convertString(src.getUrlElement())); + return tgt; + } + + static public String convertContentType(org.hl7.fhir.dstu3.model.TestScript.ContentType src) throws FHIRException { + if (src == null) return null; + switch (src) { + case XML: + return "application/fhir+xml"; + case JSON: + return "application/fhir+json"; + case TTL: + return "text/turtle"; + case NONE: + return null; + default: + return null; + } + } + + static public org.hl7.fhir.dstu3.model.TestScript.ContentType convertContentType(String src) throws FHIRException { + if (src == null) return null; + if (src.contains("xml")) return org.hl7.fhir.dstu3.model.TestScript.ContentType.XML; + if (src.contains("json")) return org.hl7.fhir.dstu3.model.TestScript.ContentType.JSON; + if (src.contains("tu")) return org.hl7.fhir.dstu3.model.TestScript.ContentType.TTL; + return org.hl7.fhir.dstu3.model.TestScript.ContentType.NONE; + } + + public static org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent(); + copyElement(src, tgt); + if (src.hasField()) tgt.setFieldElement(convertString(src.getFieldElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r4.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent(); + copyElement(src, tgt); + if (src.hasField()) tgt.setFieldElement(convertString(src.getFieldElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasDirection()) tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); + if (src.hasCompareToSourceId()) tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); + if (src.hasCompareToSourceExpression()) + tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); + if (src.hasCompareToSourcePath()) + tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasHeaderField()) tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); + if (src.hasMinimumId()) tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); + if (src.hasNavigationLinks()) tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); + if (src.hasOperator()) tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasRequestMethod()) + tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); + if (src.hasRequestURL()) tgt.setRequestURLElement(convertString(src.getRequestURLElement())); + if (src.hasResource()) tgt.setResourceElement(convertCode(src.getResourceElement())); + if (src.hasResponse()) tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); + if (src.hasResponseCode()) tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasValidateProfileId()) tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasWarningOnly()) tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasDirection()) tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); + if (src.hasCompareToSourceId()) tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); + if (src.hasCompareToSourceExpression()) + tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); + if (src.hasCompareToSourcePath()) + tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasHeaderField()) tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); + if (src.hasMinimumId()) tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); + if (src.hasNavigationLinks()) tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); + if (src.hasOperator()) tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasRequestMethod()) + tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); + if (src.hasRequestURL()) tgt.setRequestURLElement(convertString(src.getRequestURLElement())); + if (src.hasResource()) tgt.setResourceElement(convertCode(src.getResourceElement())); + if (src.hasResponse()) tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); + if (src.hasResponseCode()) tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasValidateProfileId()) tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasWarningOnly()) tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.AssertionDirectionTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.NULL); + } else { + switch (src.getValue()) { + case RESPONSE: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.RESPONSE); + break; + case REQUEST: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.REQUEST); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionDirectionType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL); + } else { + switch (src.getValue()) { + case RESPONSE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.RESPONSE); + break; + case REQUEST: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.REQUEST); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.AssertionOperatorTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NULL); + } else { + switch (src.getValue()) { + case EQUALS: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EQUALS); + break; + case NOTEQUALS: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEQUALS); + break; + case IN: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTIN); + break; + case GREATERTHAN: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.GREATERTHAN); + break; + case LESSTHAN: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.LESSTHAN); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EMPTY); + break; + case NOTEMPTY: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTEMPTY); + break; + case CONTAINS: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.CONTAINS); + break; + case NOTCONTAINS: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NOTCONTAINS); + break; + case EVAL: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.EVAL); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionOperatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorTypeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL); + } else { + switch (src.getValue()) { + case EQUALS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EQUALS); + break; + case NOTEQUALS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEQUALS); + break; + case IN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTIN); + break; + case GREATERTHAN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.GREATERTHAN); + break; + case LESSTHAN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.LESSTHAN); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EMPTY); + break; + case NOTEMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEMPTY); + break; + case CONTAINS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.CONTAINS); + break; + case NOTCONTAINS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTCONTAINS); + break; + case EVAL: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EVAL); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.NULL); + } else { + switch (src.getValue()) { + case DELETE: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.DELETE); + break; + case GET: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.GET); + break; + case OPTIONS: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.OPTIONS); + break; + case PATCH: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.PATCH); + break; + case POST: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.POST); + break; + case PUT: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.PUT); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.TestScriptRequestMethodCode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL); + } else { + switch (src.getValue()) { + case DELETE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.DELETE); + break; + case GET: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.GET); + break; + case OPTIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.OPTIONS); + break; + case PATCH: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PATCH); + break; + case POST: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.POST); + break; + case PUT: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PUT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TestScript.AssertionResponseTypesEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NULL); + } else { + switch (src.getValue()) { + case OKAY: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.OKAY); + break; + case CREATED: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CREATED); + break; + case NOCONTENT: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOCONTENT); + break; + case NOTMODIFIED: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTMODIFIED); + break; + case BAD: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.BAD); + break; + case FORBIDDEN: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.FORBIDDEN); + break; + case NOTFOUND: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NOTFOUND); + break; + case METHODNOTALLOWED: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); + break; + case CONFLICT: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.CONFLICT); + break; + case GONE: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.GONE); + break; + case PRECONDITIONFAILED: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); + break; + case UNPROCESSABLE: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TestScript.AssertionResponseTypes.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypesEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL); + } else { + switch (src.getValue()) { + case OKAY: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.OKAY); + break; + case CREATED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CREATED); + break; + case NOCONTENT: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOCONTENT); + break; + case NOTMODIFIED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTMODIFIED); + break; + case BAD: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.BAD); + break; + case FORBIDDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.FORBIDDEN); + break; + case NOTFOUND: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTFOUND); + break; + case METHODNOTALLOWED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); + break; + case CONFLICT: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CONFLICT); + break; + case GONE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.GONE); + break; + case PRECONDITIONFAILED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); + break; + case UNPROCESSABLE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestScript.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.r4.model.TestScript.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r4.model.TestScript.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r4.model.TestScript.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertFilterOperator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ValueSet.FilterOperatorEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL); + } else { + switch (src.getValue()) { + case EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EQUAL); + break; + case ISA: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISA); + break; + case DESCENDENTOF: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.DESCENDENTOF); + break; + case ISNOTA: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.ISNOTA); + break; + case REGEX: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.REGEX); + break; + case IN: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NOTIN); + break; + case GENERALIZES: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.GENERALIZES); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.EXISTS); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ValueSet.FilterOperator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertFilterOperator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ValueSet.FilterOperatorEnumFactory()); + VersionConvertor_30_40.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NULL); + } else { + switch (src.getValue()) { + case EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EQUAL); + break; + case ISA: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISA); + break; + case DESCENDENTOF: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.DESCENDENTOF); + break; + case ISNOTA: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISNOTA); + break; + case REGEX: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.REGEX); + break; + case IN: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NOTIN); + break; + case GENERALIZES: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.GENERALIZES); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EXISTS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, boolean nullOk) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.dstu3.model.Parameters) + return Parameters30_40.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu3.model.Account) + return Account30_40.convertAccount((org.hl7.fhir.dstu3.model.Account) src); + if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition) + return ActivityDefinition30_40.convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance) + return AllergyIntolerance30_40.convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Appointment) + return Appointment30_40.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); + if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) + return AppointmentResponse30_40.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) + return AuditEvent30_40.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.dstu3.model.Basic) + return Basic30_40.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); + if (src instanceof org.hl7.fhir.dstu3.model.Binary) + return Binary30_40.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); + if (src instanceof org.hl7.fhir.dstu3.model.BodySite) + return BodySite30_40.convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src); + if (src instanceof org.hl7.fhir.dstu3.model.Bundle) + return Bundle30_40.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) + return CapabilityStatement30_40.convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) + return CarePlan30_40.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); + if (src instanceof org.hl7.fhir.dstu3.model.CareTeam) + return CareTeam30_40.convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src); + if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) + return ClinicalImpression30_40.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) + return CodeSystem30_40.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.Communication) + return Communication30_40.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); + if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) + return CompartmentDefinition30_40.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Composition) + return Composition30_40.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); + if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) + return ConceptMap30_40.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu3.model.Condition) + return Condition30_40.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Consent) + return Consent30_40.convertConsent((org.hl7.fhir.dstu3.model.Consent) src); + if (src instanceof org.hl7.fhir.dstu3.model.Coverage) + return Coverage30_40.convertCoverage((org.hl7.fhir.dstu3.model.Coverage) src); + if (src instanceof org.hl7.fhir.dstu3.model.DataElement) + return DataElement30_40.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) + return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) + return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) + return DiagnosticReport30_40.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) + return DocumentReference30_40.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.dstu3.model.Encounter) + return Encounter30_40.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); + if (src instanceof org.hl7.fhir.dstu3.model.Endpoint) + return Endpoint30_40.convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src); + if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) + return EpisodeOfCare30_40.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile) + return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src); + if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) + return FamilyMemberHistory30_40.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.dstu3.model.Flag) return Flag30_40.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); + if (src instanceof org.hl7.fhir.dstu3.model.Goal) return Goal30_40.convertGoal((org.hl7.fhir.dstu3.model.Goal) src); + if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition) + return GraphDefinition30_40.convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Group) + return Group30_40.convertGroup((org.hl7.fhir.dstu3.model.Group) src); + if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) + return HealthcareService30_40.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) + return ImagingStudy30_40.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.dstu3.model.Immunization) + return Immunization30_40.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) + return ImplementationGuide30_40.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu3.model.Library) + return Library30_40.convertLibrary((org.hl7.fhir.dstu3.model.Library) src); + if (src instanceof org.hl7.fhir.dstu3.model.Linkage) + return Linkage30_40.convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src); + if (src instanceof org.hl7.fhir.dstu3.model.ListResource) + return List30_40.convertList((org.hl7.fhir.dstu3.model.ListResource) src); + if (src instanceof org.hl7.fhir.dstu3.model.Location) + return Location30_40.convertLocation((org.hl7.fhir.dstu3.model.Location) src); + if (src instanceof org.hl7.fhir.dstu3.model.Media) + return Media30_40.convertMedia((org.hl7.fhir.dstu3.model.Media) src); + if (src instanceof org.hl7.fhir.dstu3.model.Medication) + return Medication30_40.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration) + return MedicationAdministration30_40.convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) + return MedicationDispense30_40.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest) + return MedicationRequest30_40.convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) + return MedicationStatement30_40.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition) + return MessageDefinition30_40.convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) + return MessageHeader30_40.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) + return NamingSystem30_40.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.Observation) + return Observation30_40.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) + return OperationDefinition30_40.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) + return OperationOutcome30_40.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu3.model.Organization) + return Organization30_40.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); + if (src instanceof org.hl7.fhir.dstu3.model.Patient) + return Patient30_40.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); + if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice) + return PaymentNotice30_40.convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src); + if (src instanceof org.hl7.fhir.dstu3.model.Person) + return Person30_40.convertPerson((org.hl7.fhir.dstu3.model.Person) src); + if (src instanceof org.hl7.fhir.dstu3.model.PlanDefinition) + return PlanDefinition30_40.convertPlanDefinition((org.hl7.fhir.dstu3.model.PlanDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) + return Practitioner30_40.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); + if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole) + return PractitionerRole30_40.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src); + if (src instanceof org.hl7.fhir.dstu3.model.Procedure) + return Procedure30_40.convertProcedure((org.hl7.fhir.dstu3.model.Procedure) src); + if (src instanceof org.hl7.fhir.dstu3.model.ProcedureRequest) + return ProcedureRequest30_40.convertProcedureRequest((org.hl7.fhir.dstu3.model.ProcedureRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.Provenance) + return Provenance30_40.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) + return Questionnaire30_40.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) + return QuestionnaireResponse30_40.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) + return RelatedPerson30_40.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) + return RiskAssessment30_40.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.dstu3.model.Schedule) + return Schedule30_40.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); + if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) + return SearchParameter30_40.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu3.model.Sequence) + return Sequence30_40.convertSequence((org.hl7.fhir.dstu3.model.Sequence) src); + if (src instanceof org.hl7.fhir.dstu3.model.Slot) return Slot30_40.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); + if (src instanceof org.hl7.fhir.dstu3.model.Specimen) + return Specimen30_40.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); + if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) + return StructureDefinition30_40.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.StructureMap) + return StructureMap30_40.convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src); + if (src instanceof org.hl7.fhir.dstu3.model.Subscription) + return Subscription30_40.convertSubscription((org.hl7.fhir.dstu3.model.Subscription) src); + if (src instanceof org.hl7.fhir.dstu3.model.Substance) + return Substance30_40.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); + if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) + return SupplyDelivery30_40.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.dstu3.model.TestReport) + return TestReport30_40.convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src); + if (src instanceof org.hl7.fhir.dstu3.model.TestScript) + return TestScript30_40.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) + return ValueSet30_40.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); + if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType()); + else return null; + } + + public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, boolean nullOk) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r4.model.Parameters) { + if (((org.hl7.fhir.r4.model.Parameters) src).hasParameter("profile-url")) + return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.r4.model.Parameters) src); + else return Parameters30_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src); + } + if (src instanceof org.hl7.fhir.r4.model.Account) + return Account30_40.convertAccount((org.hl7.fhir.r4.model.Account) src); + if (src instanceof org.hl7.fhir.r4.model.ActivityDefinition) + return ActivityDefinition30_40.convertActivityDefinition((org.hl7.fhir.r4.model.ActivityDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.AllergyIntolerance) + return AllergyIntolerance30_40.convertAllergyIntolerance((org.hl7.fhir.r4.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.r4.model.Appointment) + return Appointment30_40.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); + if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) + return AppointmentResponse30_40.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.r4.model.AuditEvent) + return AuditEvent30_40.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.r4.model.Basic) return Basic30_40.convertBasic((org.hl7.fhir.r4.model.Basic) src); + if (src instanceof org.hl7.fhir.r4.model.Binary) + return Binary30_40.convertBinary((org.hl7.fhir.r4.model.Binary) src); + if (src instanceof org.hl7.fhir.r4.model.BodyStructure) + return BodySite30_40.convertBodySite((org.hl7.fhir.r4.model.BodyStructure) src); + if (src instanceof org.hl7.fhir.r4.model.Bundle) + return Bundle30_40.convertBundle((org.hl7.fhir.r4.model.Bundle) src); + if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) + return CapabilityStatement30_40.convertCapabilityStatement((org.hl7.fhir.r4.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r4.model.CarePlan) + return CarePlan30_40.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); + if (src instanceof org.hl7.fhir.r4.model.CareTeam) + return CareTeam30_40.convertCareTeam((org.hl7.fhir.r4.model.CareTeam) src); + if (src instanceof org.hl7.fhir.r4.model.ClinicalImpression) + return ClinicalImpression30_40.convertClinicalImpression((org.hl7.fhir.r4.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.r4.model.CodeSystem) + return CodeSystem30_40.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.r4.model.Communication) + return Communication30_40.convertCommunication((org.hl7.fhir.r4.model.Communication) src); + if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) + return CompartmentDefinition30_40.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Composition) + return Composition30_40.convertComposition((org.hl7.fhir.r4.model.Composition) src); + if (src instanceof org.hl7.fhir.r4.model.ConceptMap) + return ConceptMap30_40.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r4.model.Condition) + return Condition30_40.convertCondition((org.hl7.fhir.r4.model.Condition) src); + if (src instanceof org.hl7.fhir.r4.model.Consent) + return Consent30_40.convertConsent((org.hl7.fhir.r4.model.Consent) src); + if (src instanceof org.hl7.fhir.r4.model.Coverage) + return Coverage30_40.convertCoverage((org.hl7.fhir.r4.model.Coverage) src); + if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) + return DetectedIssue30_40.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.r4.model.Device) + return Device30_40.convertDevice((org.hl7.fhir.r4.model.Device) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) + return DeviceUseStatement30_40.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) + return DiagnosticReport30_40.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.r4.model.DocumentReference) + return DocumentReference30_40.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r4.model.Encounter) + return Encounter30_40.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); + if (src instanceof org.hl7.fhir.r4.model.Endpoint) + return Endpoint30_40.convertEndpoint((org.hl7.fhir.r4.model.Endpoint) src); + if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) + return EpisodeOfCare30_40.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) + return FamilyMemberHistory30_40.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.r4.model.Flag) return Flag30_40.convertFlag((org.hl7.fhir.r4.model.Flag) src); + if (src instanceof org.hl7.fhir.r4.model.Goal) return Goal30_40.convertGoal((org.hl7.fhir.r4.model.Goal) src); + if (src instanceof org.hl7.fhir.r4.model.GraphDefinition) + return GraphDefinition30_40.convertGraphDefinition((org.hl7.fhir.r4.model.GraphDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Group) return Group30_40.convertGroup((org.hl7.fhir.r4.model.Group) src); + if (src instanceof org.hl7.fhir.r4.model.HealthcareService) + return HealthcareService30_40.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.r4.model.ImagingStudy) + return ImagingStudy30_40.convertImagingStudy((org.hl7.fhir.r4.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.r4.model.Immunization) + return Immunization30_40.convertImmunization((org.hl7.fhir.r4.model.Immunization) src); + if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) + return ImplementationGuide30_40.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r4.model.Library) + return Library30_40.convertLibrary((org.hl7.fhir.r4.model.Library) src); + if (src instanceof org.hl7.fhir.r4.model.Linkage) + return Linkage30_40.convertLinkage((org.hl7.fhir.r4.model.Linkage) src); + if (src instanceof org.hl7.fhir.r4.model.ListResource) + return List30_40.convertList((org.hl7.fhir.r4.model.ListResource) src); + if (src instanceof org.hl7.fhir.r4.model.Location) + return Location30_40.convertLocation((org.hl7.fhir.r4.model.Location) src); + if (src instanceof org.hl7.fhir.r4.model.Media) return Media30_40.convertMedia((org.hl7.fhir.r4.model.Media) src); + if (src instanceof org.hl7.fhir.r4.model.Medication) + return Medication30_40.convertMedication((org.hl7.fhir.r4.model.Medication) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationAdministration) + return MedicationAdministration30_40.convertMedicationAdministration((org.hl7.fhir.r4.model.MedicationAdministration) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) + return MedicationDispense30_40.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationRequest) + return MedicationRequest30_40.convertMedicationRequest((org.hl7.fhir.r4.model.MedicationRequest) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) + return MedicationStatement30_40.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.r4.model.MessageDefinition) + return MessageDefinition30_40.convertMessageDefinition((org.hl7.fhir.r4.model.MessageDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.MessageHeader) + return MessageHeader30_40.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.r4.model.NamingSystem) + return NamingSystem30_40.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r4.model.Observation) + return Observation30_40.convertObservation((org.hl7.fhir.r4.model.Observation) src); + if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) + return OperationDefinition30_40.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) + return OperationOutcome30_40.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r4.model.Organization) + return Organization30_40.convertOrganization((org.hl7.fhir.r4.model.Organization) src); + if (src instanceof org.hl7.fhir.r4.model.Patient) + return Patient30_40.convertPatient((org.hl7.fhir.r4.model.Patient) src); + if (src instanceof org.hl7.fhir.r4.model.PaymentNotice) + return PaymentNotice30_40.convertPaymentNotice((org.hl7.fhir.r4.model.PaymentNotice) src); + if (src instanceof org.hl7.fhir.r4.model.Person) + return Person30_40.convertPerson((org.hl7.fhir.r4.model.Person) src); + if (src instanceof org.hl7.fhir.r4.model.PlanDefinition) + return PlanDefinition30_40.convertPlanDefinition((org.hl7.fhir.r4.model.PlanDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Practitioner) + return Practitioner30_40.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); + if (src instanceof org.hl7.fhir.r4.model.PractitionerRole) + return PractitionerRole30_40.convertPractitionerRole((org.hl7.fhir.r4.model.PractitionerRole) src); + if (src instanceof org.hl7.fhir.r4.model.Procedure) + return Procedure30_40.convertProcedure((org.hl7.fhir.r4.model.Procedure) src); + if (src instanceof org.hl7.fhir.r4.model.ServiceRequest) + return ProcedureRequest30_40.convertProcedureRequest((org.hl7.fhir.r4.model.ServiceRequest) src); + if (src instanceof org.hl7.fhir.r4.model.Provenance) + return Provenance30_40.convertProvenance((org.hl7.fhir.r4.model.Provenance) src); + if (src instanceof org.hl7.fhir.r4.model.Questionnaire) + return Questionnaire30_40.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) + return QuestionnaireResponse30_40.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r4.model.RelatedPerson) + return RelatedPerson30_40.convertRelatedPerson((org.hl7.fhir.r4.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) + return RiskAssessment30_40.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.r4.model.Schedule) + return Schedule30_40.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); + if (src instanceof org.hl7.fhir.r4.model.SearchParameter) + return SearchParameter30_40.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r4.model.MolecularSequence) + return Sequence30_40.convertSequence((org.hl7.fhir.r4.model.MolecularSequence) src); + if (src instanceof org.hl7.fhir.r4.model.Slot) return Slot30_40.convertSlot((org.hl7.fhir.r4.model.Slot) src); + if (src instanceof org.hl7.fhir.r4.model.Specimen) + return Specimen30_40.convertSpecimen((org.hl7.fhir.r4.model.Specimen) src); + if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) + return StructureDefinition30_40.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.StructureMap) + return StructureMap30_40.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); + if (src instanceof org.hl7.fhir.r4.model.Subscription) + return Subscription30_40.convertSubscription((org.hl7.fhir.r4.model.Subscription) src); + if (src instanceof org.hl7.fhir.r4.model.Substance) + return Substance30_40.convertSubstance((org.hl7.fhir.r4.model.Substance) src); + if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) + return SupplyDelivery30_40.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r4.model.TestReport) + return TestReport30_40.convertTestReport((org.hl7.fhir.r4.model.TestReport) src); + if (src instanceof org.hl7.fhir.r4.model.TestScript) + return TestScript30_40.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); + if (src instanceof org.hl7.fhir.r4.model.ValueSet) + return ValueSet30_40.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); + if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType()); + else return null; + } + + public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src, boolean b) { + TerminologyCapabilities res = new TerminologyCapabilities(); + for (ParametersParameterComponent p : src.getParameter()) { + if (p.getName().equals("system")) res.addCodeSystem().setUri(p.getValue().primitiveValue()); + } + return res; + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "ActivityDefinition", "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodyStructure", "Bundle", "CapabilityStatement", "CarePlan", "CareTeam", "ClinicalImpression", "CodeSystem", "Communication", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Consent", "DetectedIssue", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "Endpoint", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Goal", "GraphDefinition", "Group", "HealthcareService", "ImagingStudy", "Immunization", "ImplementationGuide", "Library", "Linkage", "ListResource", "Location", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationRequest", "MedicationStatement", "MessageDefinition", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "PaymentNotice", "Person", "PlanDefinition", "Practitioner", "PractitionerRole", "Procedure", "ProcedureRequest", "ProcessRequest", "Provenance", "Questionnaire", "QuestionnaireResponse", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "Slot", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "TestReport", "TestScript", "ValueSet"); + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java index 7097f9fdd..a2e062c49 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java @@ -1,5551 +1,4933 @@ package org.hl7.fhir.convertors; +import org.hl7.fhir.convertors.conv30_50.*; +import org.hl7.fhir.dstu3.model.Parameters; +import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.model.*; +import org.hl7.fhir.utilities.Utilities; + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import org.hl7.fhir.convertors.conv30_50.ActivityDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.AllergyIntolerance30_50; -import org.hl7.fhir.convertors.conv30_50.Appointment30_50; -import org.hl7.fhir.convertors.conv30_50.AppointmentResponse30_50; -import org.hl7.fhir.convertors.conv30_50.AuditEvent30_50; -import org.hl7.fhir.convertors.conv30_50.Basic30_50; -import org.hl7.fhir.convertors.conv30_50.Binary30_50; -import org.hl7.fhir.convertors.conv30_50.BodySite30_50; -import org.hl7.fhir.convertors.conv30_50.Bundle30_50; -import org.hl7.fhir.convertors.conv30_50.CapabilityStatement30_50; -import org.hl7.fhir.convertors.conv30_50.CarePlan30_50; -import org.hl7.fhir.convertors.conv30_50.CareTeam30_50; -import org.hl7.fhir.convertors.conv30_50.ClinicalImpression30_50; -import org.hl7.fhir.convertors.conv30_50.CodeSystem30_50; -import org.hl7.fhir.convertors.conv30_50.Communication30_50; -import org.hl7.fhir.convertors.conv30_50.CompartmentDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.Composition30_50; -import org.hl7.fhir.convertors.conv30_50.ConceptMap30_50; -import org.hl7.fhir.convertors.conv30_50.Condition30_50; -import org.hl7.fhir.convertors.conv30_50.Consent30_50; -import org.hl7.fhir.convertors.conv30_50.DataElement30_50; -import org.hl7.fhir.convertors.conv30_50.DetectedIssue30_50; -import org.hl7.fhir.convertors.conv30_50.DeviceUseStatement30_50; -import org.hl7.fhir.convertors.conv30_50.DiagnosticReport30_50; -import org.hl7.fhir.convertors.conv30_50.DocumentReference30_50; -import org.hl7.fhir.convertors.conv30_50.Encounter30_50; -import org.hl7.fhir.convertors.conv30_50.Endpoint30_50; -import org.hl7.fhir.convertors.conv30_50.EpisodeOfCare30_50; -import org.hl7.fhir.convertors.conv30_50.ExpansionProfile30_50; -import org.hl7.fhir.convertors.conv30_50.FamilyMemberHistory30_50; -import org.hl7.fhir.convertors.conv30_50.Flag30_50; -import org.hl7.fhir.convertors.conv30_50.Goal30_50; -import org.hl7.fhir.convertors.conv30_50.GraphDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.Group30_50; -import org.hl7.fhir.convertors.conv30_50.HealthcareService30_50; -import org.hl7.fhir.convertors.conv30_50.ImagingStudy30_50; -import org.hl7.fhir.convertors.conv30_50.Immunization30_50; -import org.hl7.fhir.convertors.conv30_50.ImplementationGuide30_50; -import org.hl7.fhir.convertors.conv30_50.Library30_50; -import org.hl7.fhir.convertors.conv30_50.Linkage30_50; -import org.hl7.fhir.convertors.conv30_50.List30_50; -import org.hl7.fhir.convertors.conv30_50.Location30_50; -import org.hl7.fhir.convertors.conv30_50.Measure30_50; -import org.hl7.fhir.convertors.conv30_50.Media30_50; -import org.hl7.fhir.convertors.conv30_50.Medication30_50; -import org.hl7.fhir.convertors.conv30_50.MedicationAdministration30_50; -import org.hl7.fhir.convertors.conv30_50.MedicationDispense30_50; -import org.hl7.fhir.convertors.conv30_50.MedicationRequest30_50; -import org.hl7.fhir.convertors.conv30_50.MedicationStatement30_50; -import org.hl7.fhir.convertors.conv30_50.MessageDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.MessageHeader30_50; -import org.hl7.fhir.convertors.conv30_50.NamingSystem30_50; -import org.hl7.fhir.convertors.conv30_50.Observation30_50; -import org.hl7.fhir.convertors.conv30_50.OperationDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.OperationOutcome30_50; -import org.hl7.fhir.convertors.conv30_50.Organization30_50; -import org.hl7.fhir.convertors.conv30_50.Parameters30_50; -import org.hl7.fhir.convertors.conv30_50.Patient30_50; -import org.hl7.fhir.convertors.conv30_50.PaymentNotice30_50; -import org.hl7.fhir.convertors.conv30_50.Person30_50; -import org.hl7.fhir.convertors.conv30_50.PlanDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.Practitioner30_50; -import org.hl7.fhir.convertors.conv30_50.PractitionerRole30_50; -import org.hl7.fhir.convertors.conv30_50.Provenance30_50; -import org.hl7.fhir.convertors.conv30_50.Questionnaire30_50; -import org.hl7.fhir.convertors.conv30_50.QuestionnaireResponse30_50; -import org.hl7.fhir.convertors.conv30_50.RelatedPerson30_50; -import org.hl7.fhir.convertors.conv30_50.RiskAssessment30_50; -import org.hl7.fhir.convertors.conv30_50.Schedule30_50; -import org.hl7.fhir.convertors.conv30_50.SearchParameter30_50; -import org.hl7.fhir.convertors.conv30_50.Sequence30_50; -import org.hl7.fhir.convertors.conv30_50.Slot30_50; -import org.hl7.fhir.convertors.conv30_50.Specimen30_50; -import org.hl7.fhir.convertors.conv30_50.StructureDefinition30_50; -import org.hl7.fhir.convertors.conv30_50.StructureMap30_50; -import org.hl7.fhir.convertors.conv30_50.Substance30_50; -import org.hl7.fhir.convertors.conv30_50.SupplyDelivery30_50; -import org.hl7.fhir.convertors.conv30_50.TestReport30_50; -import org.hl7.fhir.convertors.conv30_50.TestScript30_50; -import org.hl7.fhir.convertors.conv30_50.ValueSet30_50; -import org.hl7.fhir.dstu3.model.Parameters; -import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent; -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r5.model.CanonicalType; -import org.hl7.fhir.r5.model.CodeableReference; -import org.hl7.fhir.r5.model.DataType; -import org.hl7.fhir.r5.model.Enumerations; -import org.hl7.fhir.r5.model.Identifier; -import org.hl7.fhir.r5.model.Reference; -import org.hl7.fhir.r5.model.TerminologyCapabilities; -import org.hl7.fhir.r5.model.UriType; -import org.hl7.fhir.utilities.Utilities; - /* Copyright (c) 2011+, HL7, Inc. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + */ + public class VersionConvertor_30_50 { + static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"; + static public List CANONICAL_URLS = new ArrayList<>(); - static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"; + static { + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); + CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + } - static public List CANONICAL_URLS = new ArrayList<>(); - - static { - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); - CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); + static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } } + } - static public void copyElement(org.hl7.fhir.dstu3.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.dstu3.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } + static public void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + static public void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.r5.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + static public void copyBackboneElement(org.hl7.fhir.r5.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { + org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeType convertStringToCode(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.StringType convertCodeToString(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeType convertStringToCode(org.hl7.fhir.r5.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.StringType convertCodeToString(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDateTimeToDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { + org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { + org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { + org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r5.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { + org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { + org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DecimalType convertInteger64(org.hl7.fhir.r5.model.Integer64Type src) throws FHIRException { + org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue().toString()); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { + org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.StringType convertMarkdownToString(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { + org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { + org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UriType convertCodeToUri(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeType convertUriToCode(org.hl7.fhir.r5.model.UriType src) throws FHIRException { + org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { + org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { + org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); + copyElement(src, tgt); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu3.model.Reference) + tgt.setValue(convertReferenceToCanonical((org.hl7.fhir.dstu3.model.Reference) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); + copyElement(src, tgt); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) + if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) + tgt.setValue(convertCanonicalToReference((org.hl7.fhir.r5.model.CanonicalType) src.getValue())); + else tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(src.getDiv()); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setText(src.getText()); + return tgt; + } + + public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSize(Long.valueOf(src.getSize())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasSize()) tgt.setSize(Math.toIntExact(src.getSize())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); + copyElement(src, tgt); + tgt.setCode(src.getValue()); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeableConcept convertCodingToCodeableConcept(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.getCodingFirstRep().setSystem(src.getSystem()); + if (src.hasVersion()) tgt.getCodingFirstRep().setVersion(src.getVersion()); + if (src.hasCode()) tgt.getCodingFirstRep().setCode(src.getCode()); + if (src.hasDisplay()) tgt.getCodingFirstRep().setDisplay(src.getDisplay()); + if (src.hasUserSelected()) tgt.getCodingFirstRep().setUserSelected(src.getUserSelected()); + return tgt; + } + + public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); + copyElement(src, tgt); + if (src.hasCoding()) { + if (src.getCodingFirstRep().hasSystem()) tgt.setSystem(src.getCodingFirstRep().getSystem()); + if (src.getCodingFirstRep().hasVersion()) tgt.setVersion(src.getCodingFirstRep().getVersion()); + if (src.getCodingFirstRep().hasCode()) tgt.setCode(src.getCodingFirstRep().getCode()); + if (src.getCodingFirstRep().hasDisplay()) tgt.setDisplay(src.getCodingFirstRep().getDisplay()); + if (src.getCodingFirstRep().hasUserSelected()) tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); + copyElement(src, tgt); + if (src.hasCoding()) { + if (src.getCodingFirstRep().hasSystem()) tgt.setSystem(src.getCodingFirstRep().getSystem()); + if (src.getCodingFirstRep().hasVersion()) tgt.setVersion(src.getCodingFirstRep().getVersion()); + if (src.getCodingFirstRep().hasCode()) tgt.setCode(src.getCodingFirstRep().getCode()); + if (src.getCodingFirstRep().hasDisplay()) tgt.setDisplay(src.getCodingFirstRep().getDisplay()); + if (src.getCodingFirstRep().hasUserSelected()) tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCode()) tgt.setCurrencyElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrency()) tgt.setCodeElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static void copyQuantity(org.hl7.fhir.dstu3.model.Quantity src, org.hl7.fhir.r5.model.Quantity tgt) throws FHIRException { + if (src == null || tgt == null) return; + copyElement(src, tgt); + if (src.hasValue()) tgt.setValue(src.getValue()); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + } + + public static void copyQuantity(org.hl7.fhir.r5.model.Quantity src, org.hl7.fhir.dstu3.model.Quantity tgt) throws FHIRException { + if (src == null || tgt == null) return; + copyElement(src, tgt); + if (src.hasValue()) tgt.setValue(src.getValue()); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + } + + public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReference(src.getReference()); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensions()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasData()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensions()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasData()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhen()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) { + if (src.hasWhoUriType()) tgt.setWho(new org.hl7.fhir.r5.model.Reference(src.getWhoUriType().getValue())); + else tgt.setWho(convertReference(src.getWhoReference())); + } + if (src.hasOnBehalfOf()) { + if (src.hasOnBehalfOfUriType()) tgt.setOnBehalfOf(new Reference(src.getOnBehalfOfUriType().primitiveValue())); + else tgt.setOnBehalfOf(convertReference(src.getOnBehalfOfReference())); + } + if (src.hasContentType()) tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); + if (src.hasBlob()) tgt.setDataElement(convertBase64Binary(src.getBlobElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhen()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasOnBehalfOf()) tgt.setOnBehalfOf(convertType(src.getOnBehalfOf())); + if (src.hasSigFormat()) tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); + if (src.hasData()) tgt.setBlobElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ContactDetail convertContactDetail(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ContactDetail convertContactDetail(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.URL); + break; + case SMS: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.SMS); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL); + break; + case SMS: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.SMS); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Contributor convertContributor(org.hl7.fhir.dstu3.model.Contributor src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Contributor tgt = new org.hl7.fhir.r5.model.Contributor(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Contributor convertContributor(org.hl7.fhir.r5.model.Contributor src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Contributor tgt = new org.hl7.fhir.dstu3.model.Contributor(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContributorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Contributor.ContributorTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.NULL); + } else { + switch (src.getValue()) { + case AUTHOR: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.AUTHOR); + break; + case EDITOR: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.EDITOR); + break; + case REVIEWER: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.REVIEWER); + break; + case ENDORSER: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.ENDORSER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertContributorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Contributor.ContributorTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL); + } else { + switch (src.getValue()) { + case AUTHOR: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.AUTHOR); + break; + case EDITOR: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.EDITOR); + break; + case REVIEWER: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.REVIEWER); + break; + case ENDORSER: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.ENDORSER); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Dosage convertDosage(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Dosage tgt = new org.hl7.fhir.r5.model.Dosage(); + copyElement(src, tgt); + if (src.hasSequence()) tgt.setSequenceElement(convertInteger(src.getSequenceElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAdditionalInstruction()) + tgt.addAdditionalInstruction(convertCodeableConcept(t)); + if (src.hasPatientInstruction()) + tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertCodeableConcept(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDose() || src.hasRate()) { + org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); + if (src.hasDose()) dr.setDose(convertType(src.getDose())); + if (src.hasRate()) dr.setRate(convertType(src.getRate())); + } + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasMaxDosePerAdministration()) + tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); + if (src.hasMaxDosePerLifetime()) tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Dosage convertDosage(org.hl7.fhir.r5.model.Dosage src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); + copyElement(src, tgt); + if (src.hasSequence()) tgt.setSequenceElement(convertInteger(src.getSequenceElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r5.model.CodeableConcept t : src.getAdditionalInstruction()) + tgt.addAdditionalInstruction(convertCodeableConcept(t)); + if (src.hasPatientInstruction()) + tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertCodeableConcept(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) + tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasMaxDosePerAdministration()) + tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); + if (src.hasMaxDosePerLifetime()) tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); + if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) + tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_30_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setSliceNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) + tgt.addExample(convertElementDefinitionExampleComponent(t)); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (tgt.getIsModifier()) { + String reason = org.hl7.fhir.dstu3.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); + if (Utilities.noString(reason)) reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; + tgt.setIsModifierReason(reason); + } + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_30_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setSliceNameElement(convertString(src.getSliceNameElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) + convertTypeRefComponent(t, tgt.getType()); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) + tgt.addExample(convertElementDefinitionExampleComponent(t)); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) + org.hl7.fhir.dstu3.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + case XHTML: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XHTML); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + case XHTML: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XHTML); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertDiscriminatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL); + } else { + switch (src.getValue()) { + case VALUE: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.VALUE); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.EXISTS); + break; + case PATTERN: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PATTERN); + break; + case TYPE: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.TYPE); + break; + case PROFILE: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PROFILE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL); + } else { + switch (src.getValue()) { + case VALUE: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.VALUE); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.EXISTS); + break; + case PATTERN: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PATTERN); + break; + case TYPE: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.TYPE); + break; + case PROFILE: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PROFILE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static void convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = null; + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : list) + if (t.getCode().equals(src.getCode())) tgt = t; + if (tgt == null) { + tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCodeElement(convertUri(src.getCodeElement())); + } + if (src.hasProfile()) { + boolean found = false; + for (CanonicalType p : tgt.getProfile()) { + if (p.equals(src.getProfile())) found = true; + } + if (!found) tgt.addProfile(src.getProfile()); + } + if (src.hasTargetProfile()) tgt.addTargetProfile(src.getTargetProfile()); + for (org.hl7.fhir.dstu3.model.Enumeration t : src.getAggregation()) { + org.hl7.fhir.r5.model.Enumeration a = convertAggregationMode(t); + if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue())); + } + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + } + + public static void convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { + if (src == null) return; + org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + tgt.setCodeElement(convertUri(src.getCodeElement())); + list.add(tgt); + if (src.hasTarget()) { + if (src.hasProfile()) tgt.setProfile(src.getProfile().get(0).getValue()); + for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) { + if (tgt.hasTargetProfile()) { + tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); + if (src.hasProfile()) tgt.setProfile(src.getProfile().get(0).getValue()); } - } - - static public void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.dstu3.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) - tgt.setId(src.getId()); - for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } + tgt.setTargetProfile(u.getValue()); + } + } else { + for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { + if (tgt.hasProfile()) { + tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); + list.add(tgt); + copyElement(src, tgt); + tgt.setCode(src.getCode()); } - } - - static public void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.r5.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - static public void copyBackboneElement(org.hl7.fhir.r5.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.dstu3.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.dstu3.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.BooleanType(src.getValue()) : new org.hl7.fhir.dstu3.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeType convertStringToCode(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.StringType convertCodeToString(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeType convertStringToCode(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.StringType convertCodeToString(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateTimeType convertDateToDateTime(org.hl7.fhir.dstu3.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDateTimeToDate(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.dstu3.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IdType(src.getValue()) : new org.hl7.fhir.dstu3.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.dstu3.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r5.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.dstu3.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.dstu3.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.dstu3.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.IntegerType(src.getValue()) : new org.hl7.fhir.dstu3.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DecimalType convertInteger64(org.hl7.fhir.r5.model.Integer64Type src) throws FHIRException { - org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType(src.getValue().toString()); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.dstu3.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.MarkdownType(src.getValue()) : new org.hl7.fhir.dstu3.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.dstu3.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.OidType(src.getValue()) : new org.hl7.fhir.dstu3.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.dstu3.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.dstu3.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.StringType convertMarkdownToString(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.dstu3.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.StringType(src.getValue()) : new org.hl7.fhir.dstu3.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.dstu3.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.dstu3.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.TimeType(src.getValue()) : new org.hl7.fhir.dstu3.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.dstu3.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.dstu3.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.dstu3.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UriType(src.getValue()) : new org.hl7.fhir.dstu3.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UriType convertCodeToUri(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeType convertUriToCode(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.dstu3.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.CodeType(src.getValue()) : new org.hl7.fhir.dstu3.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.dstu3.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.dstu3.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.UuidType(src.getValue()) : new org.hl7.fhir.dstu3.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); - copyElement(src, tgt); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.dstu3.model.Reference) - tgt.setValue(convertReferenceToCanonical((org.hl7.fhir.dstu3.model.Reference) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Extension tgt = new org.hl7.fhir.dstu3.model.Extension(); - copyElement(src, tgt); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r5.model.CanonicalType) - tgt.setValue(convertCanonicalToReference((org.hl7.fhir.r5.model.CanonicalType) src.getValue())); - else - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(src.getDiv()); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.dstu3.model.Age src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Age tgt = new org.hl7.fhir.dstu3.model.Age(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.dstu3.model.Annotation src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Annotation tgt = new org.hl7.fhir.dstu3.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setText(src.getText()); - return tgt; - } - - public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.dstu3.model.Attachment src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSize(Long.valueOf(src.getSize())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Attachment tgt = new org.hl7.fhir.dstu3.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasSize()) - tgt.setSize(Math.toIntExact(src.getSize())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.CodeableConcept tgt = new org.hl7.fhir.dstu3.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeType src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); - copyElement(src, tgt); - tgt.setCode(src.getValue()); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeableConcept convertCodingToCodeableConcept(org.hl7.fhir.dstu3.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.getCodingFirstRep().setSystem(src.getSystem()); - if (src.hasVersion()) - tgt.getCodingFirstRep().setVersion(src.getVersion()); - if (src.hasCode()) - tgt.getCodingFirstRep().setCode(src.getCode()); - if (src.hasDisplay()) - tgt.getCodingFirstRep().setDisplay(src.getDisplay()); - if (src.hasUserSelected()) - tgt.getCodingFirstRep().setUserSelected(src.getUserSelected()); - return tgt; - } - - public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.dstu3.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); - copyElement(src, tgt); - if (src.hasCoding()) { - if (src.getCodingFirstRep().hasSystem()) - tgt.setSystem(src.getCodingFirstRep().getSystem()); - if (src.getCodingFirstRep().hasVersion()) - tgt.setVersion(src.getCodingFirstRep().getVersion()); - if (src.getCodingFirstRep().hasCode()) - tgt.setCode(src.getCodingFirstRep().getCode()); - if (src.getCodingFirstRep().hasDisplay()) - tgt.setDisplay(src.getCodingFirstRep().getDisplay()); - if (src.getCodingFirstRep().hasUserSelected()) - tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); - copyElement(src, tgt); - if (src.hasCoding()) { - if (src.getCodingFirstRep().hasSystem()) - tgt.setSystem(src.getCodingFirstRep().getSystem()); - if (src.getCodingFirstRep().hasVersion()) - tgt.setVersion(src.getCodingFirstRep().getVersion()); - if (src.getCodingFirstRep().hasCode()) - tgt.setCode(src.getCodingFirstRep().getCode()); - if (src.getCodingFirstRep().hasDisplay()) - tgt.setDisplay(src.getCodingFirstRep().getDisplay()); - if (src.getCodingFirstRep().hasUserSelected()) - tgt.setUserSelected(src.getCodingFirstRep().getUserSelected()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Coding tgt = new org.hl7.fhir.dstu3.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.dstu3.model.Count src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Count tgt = new org.hl7.fhir.dstu3.model.Count(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.dstu3.model.Distance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Distance tgt = new org.hl7.fhir.dstu3.model.Distance(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.dstu3.model.Duration src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Duration tgt = new org.hl7.fhir.dstu3.model.Duration(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.dstu3.model.Money src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCode()) - tgt.setCurrencyElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Money tgt = new org.hl7.fhir.dstu3.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrency()) - tgt.setCodeElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.dstu3.model.Period src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Period tgt = new org.hl7.fhir.dstu3.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static void copyQuantity(org.hl7.fhir.dstu3.model.Quantity src, org.hl7.fhir.r5.model.Quantity tgt) throws FHIRException { - if (src == null || tgt == null) - return; - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - } - - public static void copyQuantity(org.hl7.fhir.r5.model.Quantity src, org.hl7.fhir.dstu3.model.Quantity tgt) throws FHIRException { - if (src == null || tgt == null) - return; - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - } - - public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu3.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Quantity tgt = new org.hl7.fhir.dstu3.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.dstu3.model.Range src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Range tgt = new org.hl7.fhir.dstu3.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.dstu3.model.Ratio src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Ratio tgt = new org.hl7.fhir.dstu3.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Reference tgt = new org.hl7.fhir.dstu3.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReference(src.getReference()); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.dstu3.model.SampledData src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensions()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasData()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.SampledData tgt = new org.hl7.fhir.dstu3.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensions()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasData()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.dstu3.model.Signature src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhen()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) { - if (src.hasWhoUriType()) - tgt.setWho(new org.hl7.fhir.r5.model.Reference(src.getWhoUriType().getValue())); - else - tgt.setWho(convertReference(src.getWhoReference())); - } - if (src.hasOnBehalfOf()) { - if (src.hasOnBehalfOfUriType()) - tgt.setOnBehalfOf(new Reference(src.getOnBehalfOfUriType().primitiveValue())); - else - tgt.setOnBehalfOf(convertReference(src.getOnBehalfOfReference())); - } - if (src.hasContentType()) - tgt.setSigFormatElement(convertCode(src.getContentTypeElement())); - if (src.hasBlob()) - tgt.setDataElement(convertBase64Binary(src.getBlobElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Signature tgt = new org.hl7.fhir.dstu3.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhen()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasOnBehalfOf()) - tgt.setOnBehalfOf(convertType(src.getOnBehalfOf())); - if (src.hasSigFormat()) - tgt.setContentTypeElement(convertCode(src.getSigFormatElement())); - if (src.hasData()) - tgt.setBlobElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue()); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ContactDetail convertContactDetail(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ContactDetail convertContactDetail(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu3.model.ContactPoint src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ContactPoint tgt = new org.hl7.fhir.dstu3.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.URL); - break; - case SMS: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.SMS); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.URL); - break; - case SMS: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.SMS); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Contributor convertContributor(org.hl7.fhir.dstu3.model.Contributor src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Contributor tgt = new org.hl7.fhir.r5.model.Contributor(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertContributorType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Contributor convertContributor(org.hl7.fhir.r5.model.Contributor src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Contributor tgt = new org.hl7.fhir.dstu3.model.Contributor(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertContributorType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContributorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Contributor.ContributorTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case AUTHOR: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.AUTHOR); - break; - case EDITOR: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.EDITOR); - break; - case REVIEWER: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.REVIEWER); - break; - case ENDORSER: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.ENDORSER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertContributorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Contributor.ContributorTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case AUTHOR: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.AUTHOR); - break; - case EDITOR: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.EDITOR); - break; - case REVIEWER: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.REVIEWER); - break; - case ENDORSER: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.ENDORSER); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Contributor.ContributorType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Dosage convertDosage(org.hl7.fhir.dstu3.model.Dosage src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Dosage tgt = new org.hl7.fhir.r5.model.Dosage(); - copyElement(src, tgt); - if (src.hasSequence()) - tgt.setSequenceElement(convertInteger(src.getSequenceElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getAdditionalInstruction()) tgt.addAdditionalInstruction(convertCodeableConcept(t)); - if (src.hasPatientInstruction()) - tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertCodeableConcept(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDose() || src.hasRate()) { - org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent dr = tgt.addDoseAndRate(); - if (src.hasDose()) - dr.setDose(convertType(src.getDose())); - if (src.hasRate()) - dr.setRate(convertType(src.getRate())); - } - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - if (src.hasMaxDosePerAdministration()) - tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); - if (src.hasMaxDosePerLifetime()) - tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Dosage convertDosage(org.hl7.fhir.r5.model.Dosage src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Dosage tgt = new org.hl7.fhir.dstu3.model.Dosage(); - copyElement(src, tgt); - if (src.hasSequence()) - tgt.setSequenceElement(convertInteger(src.getSequenceElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r5.model.CodeableConcept t : src.getAdditionalInstruction()) tgt.addAdditionalInstruction(convertCodeableConcept(t)); - if (src.hasPatientInstruction()) - tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertCodeableConcept(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) - tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - if (src.hasMaxDosePerAdministration()) - tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); - if (src.hasMaxDosePerLifetime()) - tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); - if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) - tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_30_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setSliceNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasOrderMeaning()) - tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) tgt.addExample(convertElementDefinitionExampleComponent(t)); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.dstu3.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (tgt.getIsModifier()) { - String reason = org.hl7.fhir.dstu3.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION); - if (Utilities.noString(reason)) - reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY; - tgt.setIsModifierReason(reason); - } - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition tgt = new org.hl7.fhir.dstu3.model.ElementDefinition(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_30_50::convertPropertyRepresentation) - .collect(Collectors.toList())); if (src.hasSliceName()) - tgt.setSliceNameElement(convertString(src.getSliceNameElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType()); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasOrderMeaning()) - tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) tgt.addExample(convertElementDefinitionExampleComponent(t)); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue()); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason() && !VersionConvertorConstants.MODIFIER_REASON_LEGACY.equals(src.getIsModifierReason())) - org.hl7.fhir.dstu3.utils.ToolingExtensions.setStringExtension(tgt, VersionConvertorConstants.MODIFIER_REASON_EXTENSION, src.getIsModifierReason()); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - case XHTML: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XHTML); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - case XHTML: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.XHTML); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertDiscriminatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case VALUE: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.VALUE); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.EXISTS); - break; - case PATTERN: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PATTERN); - break; - case TYPE: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.TYPE); - break; - case PROFILE: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PROFILE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case VALUE: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.VALUE); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.EXISTS); - break; - case PATTERN: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PATTERN); - break; - case TYPE: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.TYPE); - break; - case PROFILE: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.PROFILE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.DiscriminatorType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static void convertTypeRefComponent(org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = null; - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : list) if (t.getCode().equals(src.getCode())) - tgt = t; - if (tgt == null) { - tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCodeElement(convertUri(src.getCodeElement())); - } - if (src.hasProfile()) { - boolean found = false; - for (CanonicalType p : tgt.getProfile()) { - if (p.equals(src.getProfile())) - found = true; - } - if (!found) - tgt.addProfile(src.getProfile()); - } - if (src.hasTargetProfile()) - tgt.addTargetProfile(src.getTargetProfile()); - for (org.hl7.fhir.dstu3.model.Enumeration t : src.getAggregation()) { - org.hl7.fhir.r5.model.Enumeration a = convertAggregationMode(t); - if (!tgt.hasAggregation(a.getValue())) - copyElement(t, tgt.addAggregation(a.getValue())); - } - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - } - - public static void convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src, List list) throws FHIRException { - if (src == null) - return; - org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - tgt.setCodeElement(convertUri(src.getCodeElement())); - list.add(tgt); - if (src.hasTarget()) { - if (src.hasProfile()) - tgt.setProfile(src.getProfile().get(0).getValue()); - for (org.hl7.fhir.r5.model.UriType u : src.getTargetProfile()) { - if (tgt.hasTargetProfile()) { - tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - if (src.hasProfile()) - tgt.setProfile(src.getProfile().get(0).getValue()); - } - tgt.setTargetProfile(u.getValue()); - } + tgt.setProfile(u.getValue()); + } + } + } + + static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKey()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHuman()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpath()) tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasSource()) tgt.setSource(src.getSource()); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKey()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHuman()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpath()) tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasSource()) tgt.setSource(src.getSource()); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt, EXT_SRC_TYPE); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + DataType t = convertType(src.getValueSet()); + if (t instanceof org.hl7.fhir.r5.model.Reference) { + tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference()); + tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("Reference")); + } else { + tgt.setValueSet(t.primitiveValue()); + tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("uri")); + } + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt, EXT_SRC_TYPE); + if (src.hasStrength()) tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) { + org.hl7.fhir.r5.model.Extension ex = src.getValueSetElement().getExtensionByUrl(EXT_SRC_TYPE); + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (ex != null) { + if ("uri".equals(ex.getValue().primitiveValue())) { + tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr == null ? src.getValueSet() : vsr)); } else { - for (org.hl7.fhir.r5.model.UriType u : src.getProfile()) { - if (tgt.hasProfile()) { - tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent(); - list.add(tgt); - copyElement(src, tgt); - tgt.setCode(src.getCode()); - } - tgt.setProfile(u.getValue()); - } - } - } - - static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionExampleComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKey()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHuman()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpath()) - tgt.setXpathElement(convertString(src.getXpathElement())); - if (src.hasSource()) - tgt.setSource(src.getSource()); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKey()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHuman()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpath()) - tgt.setXpathElement(convertString(src.getXpathElement())); - if (src.hasSource()) - tgt.setSource(src.getSource()); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt, EXT_SRC_TYPE); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - DataType t = convertType(src.getValueSet()); - if (t instanceof org.hl7.fhir.r5.model.Reference) { - tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference()); - tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("Reference")); - } else { - tgt.setValueSet(t.primitiveValue()); - tgt.getValueSetElement().addExtension(EXT_SRC_TYPE, new UriType("uri")); - } - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt, EXT_SRC_TYPE); - if (src.hasStrength()) - tgt.setStrengthElement(convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) { - org.hl7.fhir.r5.model.Extension ex = src.getValueSetElement().getExtensionByUrl(EXT_SRC_TYPE); - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (ex != null) { - if ("uri".equals(ex.getValue().primitiveValue())) { - tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr == null ? src.getValueSet() : vsr)); - } else { - tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); - } - } else { - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); - } - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case REQUIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); - break; - case EXTENSIBLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); - break; - case PREFERRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); - break; - case EXAMPLE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentity()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMap()) - tgt.setMapElement(convertString(src.getMapElement())); - if (src.hasComment()) - tgt.setCommentElement(convertString(src.getCommentElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentity()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMap()) - tgt.setMapElement(convertString(src.getMapElement())); - if (src.hasComment()) - tgt.setCommentElement(convertString(src.getCommentElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.setFamilyElement(convertString(src.getFamilyElement())); - for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.setFamilyElement(convertString(src.getFamilyElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.dstu3.model.ParameterDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ParameterDefinition tgt = new org.hl7.fhir.r5.model.ParameterDefinition(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertCode(src.getNameElement())); - if (src.hasUse()) - tgt.setUseElement(convertParameterUse(src.getUseElement())); - if (src.hasMin()) - tgt.setMinElement(convertInteger(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasDocumentation()) - tgt.setDocumentationElement(convertString(src.getDocumentationElement())); - if (src.hasType()) - tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); - if (src.hasProfile()) { - tgt.setProfile(convertReference(src.getProfile()).getReference()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.ParameterDefinition tgt = new org.hl7.fhir.dstu3.model.ParameterDefinition(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertCode(src.getNameElement())); - if (src.hasUse()) - tgt.setUseElement(convertParameterUse(src.getUseElement())); - if (src.hasMin()) - tgt.setMinElement(convertInteger(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasDocumentation()) - tgt.setDocumentationElement(convertString(src.getDocumentationElement())); - if (src.hasType()) - tgt.setType(src.getType().toCode()); - if (src.hasProfile()) - tgt.setProfile(new org.hl7.fhir.dstu3.model.Reference(src.getProfile())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertParameterUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.OperationParameterUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case IN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.IN); - break; - case OUT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.OUT); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertParameterUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUseEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case IN: - tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.IN); - break; - case OUT: - tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.OUT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.RelatedArtifact tgt = new org.hl7.fhir.r5.model.RelatedArtifact(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasCitation()) - tgt.setCitation(src.getCitation()); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasDocument()) - tgt.setDocument(convertAttachment(src.getDocument())); - if (src.hasResource()) - tgt.setResourceElement(convertReferenceToCanonical(src.getResource())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.RelatedArtifact tgt = new org.hl7.fhir.dstu3.model.RelatedArtifact(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasCitation()) - tgt.setCitation(src.getCitation()); - if (src.hasUrl()) - tgt.setUrl(src.getUrl()); - if (src.hasDocument()) - tgt.setDocument(convertAttachment(src.getDocument())); - if (src.hasResource()) - tgt.setResource(convertCanonicalToReference(src.getResourceElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DOCUMENTATION: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); - break; - case JUSTIFICATION: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); - break; - case CITATION: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.CITATION); - break; - case PREDECESSOR: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); - break; - case SUCCESSOR: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); - break; - case DERIVEDFROM: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); - break; - case DEPENDSON: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - break; - case COMPOSEDOF: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DOCUMENTATION: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); - break; - case JUSTIFICATION: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); - break; - case CITATION: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.CITATION); - break; - case PREDECESSOR: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); - break; - case SUCCESSOR: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); - break; - case DERIVEDFROM: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); - break; - case DEPENDSON: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - break; - case COMPOSEDOF: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - tgt.setDayOfWeek(src.getDayOfWeek().stream() - .map(VersionConvertor_30_50::convertDayOfWeek) - .collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream() - .map(VersionConvertor_30_50::convertEventTiming) - .collect(Collectors.toList())); - for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCount(src.getCount()); - if (src.hasCountMax()) - tgt.setCountMax(src.getCountMax()); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequency(src.getFrequency()); - if (src.hasFrequencyMax()) - tgt.setFrequencyMax(src.getFrequencyMax()); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - tgt.setDayOfWeek(src.getDayOfWeek().stream() - .map(VersionConvertor_30_50::convertDayOfWeek) - .collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream() - .map(VersionConvertor_30_50::convertEventTiming) - .collect(Collectors.toList())); - for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertDayOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertDayOfWeek(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.DayOfWeekEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MORN: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN); - break; - case AFT: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT); - break; - case EVE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE); - break; - case NIGHT: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NIGHT); - break; - case PHS: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PHS); - break; - case HS: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MORN: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.MORN); - break; - case AFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AFT); - break; - case EVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.EVE); - break; - case NIGHT: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NIGHT); - break; - case PHS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PHS); - break; - case HS: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.UsageContext convertUsageContext(org.hl7.fhir.dstu3.model.UsageContext src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.UsageContext tgt = new org.hl7.fhir.r5.model.UsageContext(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(convertCoding(src.getCode())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.UsageContext convertUsageContext(org.hl7.fhir.r5.model.UsageContext src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.UsageContext tgt = new org.hl7.fhir.dstu3.model.UsageContext(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(convertCoding(src.getCode())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.SimpleQuantity tgt = new org.hl7.fhir.r5.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.dstu3.model.TriggerDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TriggerDefinition tgt = new org.hl7.fhir.r5.model.TriggerDefinition(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertTriggerType(src.getTypeElement())); - if (src.hasEventName()) - tgt.setNameElement(convertString(src.getEventNameElement())); - if (src.hasEventTiming()) - tgt.setTiming(convertType(src.getEventTiming())); - if (src.hasEventData()) - tgt.addData(convertDataRequirement(src.getEventData())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r5.model.TriggerDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TriggerDefinition tgt = new org.hl7.fhir.dstu3.model.TriggerDefinition(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertTriggerType(src.getTypeElement())); - if (src.hasName()) - tgt.setEventNameElement(convertString(src.getNameElement())); - if (src.hasTiming()) - tgt.setEventTiming(convertType(src.getTiming())); - if (src.hasData()) - tgt.setEventData(convertDataRequirement(src.getDataFirstRep())); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement convertDataRequirement(org.hl7.fhir.dstu3.model.DataRequirement src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement tgt = new org.hl7.fhir.r5.model.DataRequirement(); - copyElement(src, tgt, VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME); - if (src.hasType()) { - if (src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { - tgt.setType(Enumerations.FHIRAllTypes.fromCode(src.getExtensionString(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME))); - } else { - String n = VersionConvertorResourceNameMapper.mapName3to5(src.getType()); - if (n != null) { - tgt.setType(Enumerations.FHIRAllTypes.fromCode(n)); - } - tgt.addExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME, new org.hl7.fhir.r5.model.CodeType(src.getType())); - } - } - for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.dstu3.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); - for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); - for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DataRequirement convertDataRequirement(org.hl7.fhir.r5.model.DataRequirement src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DataRequirement tgt = new org.hl7.fhir.dstu3.model.DataRequirement(); - copyElement(src, tgt, VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME); - if (src.hasType() || src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { - if (src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { - tgt.setType(src.getExtensionString(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)); - } else { - String n = VersionConvertorResourceNameMapper.mapName5to3(src.getType().toCode()); - if (n != null) { - tgt.setType(n); - } - tgt.addExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME, new org.hl7.fhir.dstu3.model.CodeType(src.getType().toCode())); - } - } - for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); - for (org.hl7.fhir.r5.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); - for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); - for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValueSet()) { - DataType t = convertType(src.getValueSet()); - if (t instanceof org.hl7.fhir.r5.model.Reference) - tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference()); - else - tgt.setValueSet(t.primitiveValue()); - tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); - } - for (org.hl7.fhir.dstu3.model.CodeType t : src.getValueCode()) tgt.addCode(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.Coding t : src.getValueCoding()) tgt.addCode(convertCoding(t)); - for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getValueCodeableConcept()) tgt.addCode(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValueSet()) { - String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); - if (vsr != null) - tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); - else - tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); - } - for (org.hl7.fhir.r5.model.Coding t : src.getCode()) { - tgt.addValueCoding(convertCoding(t)); - } - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertTriggerType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TriggerDefinition.TriggerTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case NAMEDEVENT: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NAMEDEVENT); - break; - case PERIODIC: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.PERIODIC); - break; - case DATAADDED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAADDED); - break; - case DATAMODIFIED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAMODIFIED); - break; - case DATAREMOVED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAREMOVED); - break; - case DATAACCESSED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSED); - break; - case DATAACCESSENDED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSENDED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertTriggerType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case NAMEDEVENT: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NAMEDEVENT); - break; - case PERIODIC: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.PERIODIC); - break; - case DATAADDED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAADDED); - break; - case DATAMODIFIED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAMODIFIED); - break; - case DATAREMOVED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAREMOVED); - break; - case DATAACCESSED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSED); - break; - case DATAACCESSENDED: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSENDED); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) - return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeType) - return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateType) - return convertDate((org.hl7.fhir.dstu3.model.DateType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) - return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) - return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IdType) - return convertId((org.hl7.fhir.dstu3.model.IdType) src); - if (src instanceof org.hl7.fhir.dstu3.model.InstantType) - return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); - if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) - return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); - if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.dstu3.model.OidType) - return convertOid((org.hl7.fhir.dstu3.model.OidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.StringType) - return convertString((org.hl7.fhir.dstu3.model.StringType) src); - if (src instanceof org.hl7.fhir.dstu3.model.TimeType) - return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UriType) - return convertUri((org.hl7.fhir.dstu3.model.UriType) src); - if (src instanceof org.hl7.fhir.dstu3.model.UuidType) - return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); - if (src instanceof org.hl7.fhir.dstu3.model.Extension) - return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); - if (src instanceof org.hl7.fhir.dstu3.model.Narrative) - return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); - if (src instanceof org.hl7.fhir.dstu3.model.Age) - return convertAge((org.hl7.fhir.dstu3.model.Age) src); - if (src instanceof org.hl7.fhir.dstu3.model.Annotation) - return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); - if (src instanceof org.hl7.fhir.dstu3.model.Attachment) - return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.dstu3.model.Coding) - return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); - if (src instanceof org.hl7.fhir.dstu3.model.Count) - return convertCount((org.hl7.fhir.dstu3.model.Count) src); - if (src instanceof org.hl7.fhir.dstu3.model.Distance) - return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Duration) - return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); - if (src instanceof org.hl7.fhir.dstu3.model.Identifier) - return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); - if (src instanceof org.hl7.fhir.dstu3.model.Money) - return convertMoney((org.hl7.fhir.dstu3.model.Money) src); - if (src instanceof org.hl7.fhir.dstu3.model.Period) - return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); - if (src instanceof org.hl7.fhir.dstu3.model.Quantity) - return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); - if (src instanceof org.hl7.fhir.dstu3.model.Range) - return convertRange((org.hl7.fhir.dstu3.model.Range) src); - if (src instanceof org.hl7.fhir.dstu3.model.Ratio) - return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); - if (src instanceof org.hl7.fhir.dstu3.model.Reference) - return convertReference((org.hl7.fhir.dstu3.model.Reference) src); - if (src instanceof org.hl7.fhir.dstu3.model.SampledData) - return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); - if (src instanceof org.hl7.fhir.dstu3.model.Signature) - return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); - if (src instanceof org.hl7.fhir.dstu3.model.Address) - return convertAddress((org.hl7.fhir.dstu3.model.Address) src); - if (src instanceof org.hl7.fhir.dstu3.model.ContactDetail) - return convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) src); - if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.dstu3.model.Contributor) - return convertContributor((org.hl7.fhir.dstu3.model.Contributor) src); - if (src instanceof org.hl7.fhir.dstu3.model.Dosage) - return convertDosage((org.hl7.fhir.dstu3.model.Dosage) src); - if (src instanceof org.hl7.fhir.dstu3.model.HumanName) - return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); - if (src instanceof org.hl7.fhir.dstu3.model.Meta) - return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); - if (src instanceof org.hl7.fhir.dstu3.model.ParameterDefinition) - return convertParameterDefinition((org.hl7.fhir.dstu3.model.ParameterDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.RelatedArtifact) - return convertRelatedArtifact((org.hl7.fhir.dstu3.model.RelatedArtifact) src); - if (src instanceof org.hl7.fhir.dstu3.model.Timing) - return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); - if (src instanceof org.hl7.fhir.dstu3.model.UsageContext) - return convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) src); - if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.DataRequirement) - return convertDataRequirement((org.hl7.fhir.dstu3.model.DataRequirement) src); - if (src instanceof org.hl7.fhir.dstu3.model.TriggerDefinition) - return convertTriggerDefinition((org.hl7.fhir.dstu3.model.TriggerDefinition) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r5.model.BooleanType) - return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r5.model.CodeType) - return convertCode((org.hl7.fhir.r5.model.CodeType) src); - if (src instanceof org.hl7.fhir.r5.model.DateType) - return convertDate((org.hl7.fhir.r5.model.DateType) src); - if (src instanceof org.hl7.fhir.r5.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r5.model.DecimalType) - return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r5.model.IdType) - return convertId((org.hl7.fhir.r5.model.IdType) src); - if (src instanceof org.hl7.fhir.r5.model.InstantType) - return convertInstant((org.hl7.fhir.r5.model.InstantType) src); - if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r5.model.Integer64Type) - return convertInteger64((org.hl7.fhir.r5.model.Integer64Type) src); - if (src instanceof org.hl7.fhir.r5.model.IntegerType) - return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r5.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r5.model.OidType) - return convertOid((org.hl7.fhir.r5.model.OidType) src); - if (src instanceof org.hl7.fhir.r5.model.StringType) - return convertString((org.hl7.fhir.r5.model.StringType) src); - if (src instanceof org.hl7.fhir.r5.model.TimeType) - return convertTime((org.hl7.fhir.r5.model.TimeType) src); - if (src instanceof org.hl7.fhir.r5.model.UriType) - return convertUri((org.hl7.fhir.r5.model.UriType) src); - if (src instanceof org.hl7.fhir.r5.model.UuidType) - return convertUuid((org.hl7.fhir.r5.model.UuidType) src); - if (src instanceof org.hl7.fhir.r5.model.Extension) - return convertExtension((org.hl7.fhir.r5.model.Extension) src); - if (src instanceof org.hl7.fhir.r5.model.Narrative) - return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); - if (src instanceof org.hl7.fhir.r5.model.Age) - return convertAge((org.hl7.fhir.r5.model.Age) src); - if (src instanceof org.hl7.fhir.r5.model.Annotation) - return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); - if (src instanceof org.hl7.fhir.r5.model.Attachment) - return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); - if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r5.model.Coding) - return convertCoding((org.hl7.fhir.r5.model.Coding) src); - if (src instanceof org.hl7.fhir.r5.model.Count) - return convertCount((org.hl7.fhir.r5.model.Count) src); - if (src instanceof org.hl7.fhir.r5.model.Distance) - return convertDistance((org.hl7.fhir.r5.model.Distance) src); - if (src instanceof org.hl7.fhir.r5.model.Duration) - return convertDuration((org.hl7.fhir.r5.model.Duration) src); - if (src instanceof org.hl7.fhir.r5.model.Identifier) - return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); - if (src instanceof org.hl7.fhir.r5.model.Money) - return convertMoney((org.hl7.fhir.r5.model.Money) src); - if (src instanceof org.hl7.fhir.r5.model.Period) - return convertPeriod((org.hl7.fhir.r5.model.Period) src); - if (src instanceof org.hl7.fhir.r5.model.Quantity) - return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); - if (src instanceof org.hl7.fhir.r5.model.Range) - return convertRange((org.hl7.fhir.r5.model.Range) src); - if (src instanceof org.hl7.fhir.r5.model.Ratio) - return convertRatio((org.hl7.fhir.r5.model.Ratio) src); - if (src instanceof org.hl7.fhir.r5.model.Reference) - return convertReference((org.hl7.fhir.r5.model.Reference) src); - if (src instanceof org.hl7.fhir.r5.model.SampledData) - return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); - if (src instanceof org.hl7.fhir.r5.model.Signature) - return convertSignature((org.hl7.fhir.r5.model.Signature) src); - if (src instanceof org.hl7.fhir.r5.model.Address) - return convertAddress((org.hl7.fhir.r5.model.Address) src); - if (src instanceof org.hl7.fhir.r5.model.ContactDetail) - return convertContactDetail((org.hl7.fhir.r5.model.ContactDetail) src); - if (src instanceof org.hl7.fhir.r5.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r5.model.Contributor) - return convertContributor((org.hl7.fhir.r5.model.Contributor) src); - if (src instanceof org.hl7.fhir.r5.model.Dosage) - return convertDosage((org.hl7.fhir.r5.model.Dosage) src); - if (src instanceof org.hl7.fhir.r5.model.HumanName) - return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); - if (src instanceof org.hl7.fhir.r5.model.Meta) - return convertMeta((org.hl7.fhir.r5.model.Meta) src); - if (src instanceof org.hl7.fhir.r5.model.ParameterDefinition) - return convertParameterDefinition((org.hl7.fhir.r5.model.ParameterDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.RelatedArtifact) - return convertRelatedArtifact((org.hl7.fhir.r5.model.RelatedArtifact) src); - if (src instanceof org.hl7.fhir.r5.model.Timing) - return convertTiming((org.hl7.fhir.r5.model.Timing) src); - if (src instanceof org.hl7.fhir.r5.model.UsageContext) - return convertUsageContext((org.hl7.fhir.r5.model.UsageContext) src); - if (src instanceof org.hl7.fhir.r5.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.r5.model.ElementDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.DataRequirement) - return convertDataRequirement((org.hl7.fhir.r5.model.DataRequirement) src); - if (src instanceof org.hl7.fhir.r5.model.TriggerDefinition) - return convertTriggerDefinition((org.hl7.fhir.r5.model.TriggerDefinition) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); - for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) { - if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t2)); - } - for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) { - if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t3)); - } - } - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) if (s.equals(url)) - ok = true; - return ok; - } - - static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r5.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); - for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) { - if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) - tgt.addExtension(convertExtension(t2)); - } - for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) { - if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) - tgt.addModifierExtension(convertExtension(t3)); - } - } - - static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setIdElement(convertId(src.getIdElement())); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - } - - static public void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setIdElement(convertId(src.getIdElement())); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRules(src.getImplicitRules()); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - } - - static public org.hl7.fhir.r5.model.Enumeration convertPublicationStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.RETIRED); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertPublicationStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DRAFT: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); - break; - case ACTIVE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); - break; - case RETIRED: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); - break; - } - return tgt; - } - - static public CodeableReference convertReferenceToCodableReference(org.hl7.fhir.dstu3.model.Reference src) { - CodeableReference tgt = new CodeableReference(); - tgt.setReference(convertReference(src)); - return tgt; - } - - static public CodeableReference convertCodeableConceptToCodableReference(org.hl7.fhir.dstu3.model.CodeableConcept src) { - CodeableReference tgt = new CodeableReference(); - tgt.setConcept(convertCodeableConcept(src)); - return tgt; - } - - static public org.hl7.fhir.r5.model.CanonicalType convertReferenceToCanonical(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { - org.hl7.fhir.r5.model.CanonicalType dst = new org.hl7.fhir.r5.model.CanonicalType(src.getReference()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.dstu3.model.Reference convertCanonicalToReference(org.hl7.fhir.r5.model.CanonicalType src) throws FHIRException { - org.hl7.fhir.dstu3.model.Reference dst = new org.hl7.fhir.dstu3.model.Reference(src.getValue()); - copyElement(src, dst); - return dst; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case NUMBER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); - break; - case DATE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); - break; - case STRING: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); - break; - case TOKEN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); - break; - case REFERENCE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); - break; - case COMPOSITE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); - break; - case QUANTITY: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); - break; - case URI: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertFilterOperator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CodeSystem.FilterOperatorEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case EQUAL: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.EQUAL); - break; - case ISA: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.ISA); - break; - case DESCENDENTOF: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.DESCENDENTOF); - break; - case ISNOTA: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.ISNOTA); - break; - case REGEX: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.REGEX); - break; - case IN: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NOTIN); - break; - case GENERALIZES: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.GENERALIZES); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.EXISTS); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent(); - copyElement(src, tgt); - if (src.hasAuthority()) - tgt.setAuthorityElement(convertUri(src.getAuthorityElement())); - if (src.hasUri()) - tgt.setUriElement(convertUri(src.getUriElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent(); - copyElement(src, tgt); - if (src.hasAuthority()) - tgt.setAuthorityElement(convertUri(src.getAuthorityElement())); - if (src.hasUri()) - tgt.setUriElement(convertUri(src.getUriElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConsentDataMeaning(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Consent.ConsentDataMeaningEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case INSTANCE: - tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.INSTANCE); - break; - case RELATED: - tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.RELATED); - break; - case DEPENDENTS: - tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.DEPENDENTS); - break; - case AUTHOREDBY: - tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.AUTHOREDBY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertConsentDataMeaning(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaningEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case INSTANCE: - tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.INSTANCE); - break; - case RELATED: - tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.RELATED); - break; - case DEPENDENTS: - tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.DEPENDENTS); - break; - case AUTHOREDBY: - tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.AUTHOREDBY); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent(); - copyElement(src, tgt); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasRef()) - tgt.setRef(convertReference(src.getRef())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertDocumentRelationshipType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case REPLACES: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.REPLACES); - break; - case TRANSFORMS: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.TRANSFORMS); - break; - case SIGNS: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.SIGNS); - break; - case APPENDS: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.APPENDS); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.Encounter.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasRole()) - tgt.setUse(convertCodeableConcept(src.getRole())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.Encounter.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasUse()) - tgt.setRole(convertCodeableConcept(src.getUse())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasRole()) - tgt.setRole(convertCodeableConcept(src.getRole())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent(); - copyElement(src, tgt); - if (src.hasCondition()) - tgt.setCondition(convertReference(src.getCondition())); - if (src.hasRole()) - tgt.setRole(convertCodeableConcept(src.getRole())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); - break; - case FEMALE: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); - break; - case UNKNOWN: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); - break; - } - return tgt; - } - - private static final String CODE_SYSTEM_MEDIA_TYPE = "http://terminology.hl7.org/CodeSystem/media-type"; - - public static String convertCoding2Uri(org.hl7.fhir.dstu3.model.Coding code) { - return code.getSystem() + "/" + code.getCode(); - } - - public static org.hl7.fhir.dstu3.model.Coding convertUri2Coding(String uri) { - int i = uri.lastIndexOf("/"); - return new org.hl7.fhir.dstu3.model.Coding().setSystem(uri.substring(0, i)).setCode(uri.substring(i + 1)); - } - - static public org.hl7.fhir.r5.model.Enumeration convertDaysOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Provenance convertProvenance(org.hl7.fhir.dstu3.model.Provenance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Provenance tgt = new org.hl7.fhir.r5.model.Provenance(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.dstu3.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t)); - if (src.hasPeriod()) - tgt.setOccurred(convertPeriod(src.getPeriod())); - if (src.hasRecorded()) - tgt.setRecordedElement(convertInstant(src.getRecordedElement())); - for (org.hl7.fhir.dstu3.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue()); - if (src.hasLocation()) - tgt.setLocation(convertReference(src.getLocation())); - for (org.hl7.fhir.dstu3.model.Coding t : src.getReason()) tgt.addReason(convertCodingToCodeableConcept(t)); - if (src.hasActivity()) - tgt.setActivity(convertCodingToCodeableConcept(src.getActivity())); - for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t)); - for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) tgt.addEntity(convertProvenanceEntityComponent(t)); - for (org.hl7.fhir.dstu3.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Provenance convertProvenance(org.hl7.fhir.r5.model.Provenance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Provenance tgt = new org.hl7.fhir.dstu3.model.Provenance(); - copyDomainResource(src, tgt); - for (org.hl7.fhir.r5.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t)); - if (src.hasOccurredPeriod()) - tgt.setPeriod(convertPeriod(src.getOccurredPeriod())); - if (src.hasRecorded()) - tgt.setRecordedElement(convertInstant(src.getRecordedElement())); - for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue()); - if (src.hasLocation()) - tgt.setLocation(convertReference(src.getLocation())); - for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReason()) for (org.hl7.fhir.r5.model.Coding tc : t.getCoding()) tgt.addReason(convertCoding(tc)); - if (src.hasActivity()) - tgt.setActivity(convertCoding(src.getActivity())); - for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t)); - for (org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) tgt.addEntity(convertProvenanceEntityComponent(t)); - for (org.hl7.fhir.r5.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t)); - if (src.hasWho()) { - DataType t = convertType(src.getWho()); - if (t instanceof Reference) - tgt.setWho((Reference) t); - if (t instanceof UriType) - tgt.getWho().setReference(t.primitiveValue()); - } - if (src.hasOnBehalfOf()) { - DataType t = convertType(src.getOnBehalfOf()); - if (t instanceof Reference) - tgt.setOnBehalfOf((Reference) t); - if (t instanceof UriType) - tgt.getOnBehalfOf().setReference(t.primitiveValue()); - } - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t)); - if (src.hasWho()) - tgt.setWho(convertType(src.getWho())); - if (src.hasOnBehalfOf()) - tgt.setOnBehalfOf(convertType(src.getOnBehalfOf())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent(); - copyElement(src, tgt); - if (src.hasRole()) - tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement())); - if (src.hasWhat()) { - DataType t = convertType(src.getWhat()); - if (t instanceof Reference) - tgt.setWhat((Reference) t); - else if (t instanceof Identifier) - tgt.getWhat().setIdentifier((Identifier) t); - else if (t instanceof UriType) - tgt.getWhat().setReference(t.primitiveValue()); - } - for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t)); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent(); - copyElement(src, tgt); - if (src.hasRole()) - tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement())); - if (src.hasWhat()) - tgt.setWhat(convertType(src.getWhat())); - for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertProvenanceEntityRole(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRoleEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DERIVATION: - tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.DERIVATION); - break; - case REVISION: - tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REVISION); - break; - case QUOTATION: - tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.QUOTATION); - break; - case SOURCE: - tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.SOURCE); - break; - case REMOVAL: - tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REMOVAL); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertProvenanceEntityRole(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRoleEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DERIVATION: - tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.DERIVATION); - break; - case REVISION: - tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REVISION); - break; - case QUOTATION: - tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.QUOTATION); - break; - case SOURCE: - tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.SOURCE); - break; - case REMOVAL: - tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REMOVAL); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.r5.model.TestReport.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r5.model.TestReport.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertUri(src.getDetailElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertUri(src.getDetailElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertTestReportActionResult(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestReport.TestReportActionResultEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case PASS: - tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.PASS); - break; - case SKIP: - tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.SKIP); - break; - case FAIL: - tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.FAIL); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.WARNING); - break; - case ERROR: - tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.ERROR); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertTestReportActionResult(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestReport.TestReportActionResultEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case PASS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.PASS); - break; - case SKIP: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.SKIP); - break; - case FAIL: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.FAIL); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.WARNING); - break; - case ERROR: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.ERROR); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertString(src.getDetailElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasResult()) - tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); - if (src.hasMessage()) - tgt.setMessageElement(convertMarkdown(src.getMessageElement())); - if (src.hasDetail()) - tgt.setDetailElement(convertString(src.getDetailElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestReport.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.r5.model.TestReport.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.r5.model.TestReport.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.r5.model.TestReport.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r5.model.TestReport.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r5.model.TestScript.SetupActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCoding(src.getType())); - if (src.hasResource()) - tgt.setResource(org.hl7.fhir.r5.model.TestScript.FHIRDefinedType.fromCode(src.getResource())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasAccept()) - tgt.setAccept(convertContentType(src.getAccept())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasDestination()) - tgt.setDestinationElement(convertInteger(src.getDestinationElement())); - if (src.hasEncodeRequestUrl()) - tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); - if (src.hasOrigin()) - tgt.setOriginElement(convertInteger(src.getOriginElement())); - if (src.hasParams()) - tgt.setParamsElement(convertString(src.getParamsElement())); - for (org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); - if (src.hasRequestId()) - tgt.setRequestIdElement(convertId(src.getRequestIdElement())); - if (src.hasResponseId()) - tgt.setResponseIdElement(convertId(src.getResponseIdElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasTargetId()) - tgt.setTargetId(src.getTargetId()); - if (src.hasUrl()) - tgt.setUrlElement(convertString(src.getUrlElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCoding(src.getType())); - if (src.hasResource()) - tgt.setResource(src.getResource().toCode()); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasAccept()) - tgt.setAccept(convertContentType(src.getAccept())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasDestination()) - tgt.setDestinationElement(convertInteger(src.getDestinationElement())); - if (src.hasEncodeRequestUrl()) - tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); - if (src.hasOrigin()) - tgt.setOriginElement(convertInteger(src.getOriginElement())); - if (src.hasParams()) - tgt.setParamsElement(convertString(src.getParamsElement())); - for (org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); - if (src.hasRequestId()) - tgt.setRequestIdElement(convertId(src.getRequestIdElement())); - if (src.hasResponseId()) - tgt.setResponseIdElement(convertId(src.getResponseIdElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasTargetId()) - tgt.setTargetId(src.getTargetId()); - if (src.hasUrl()) - tgt.setUrlElement(convertString(src.getUrlElement())); - return tgt; - } - - static public String convertContentType(org.hl7.fhir.dstu3.model.TestScript.ContentType src) throws FHIRException { - if (src == null) - return null; - switch(src) { - case XML: - return "application/fhir+xml"; - case JSON: - return "application/fhir+json"; - case TTL: - return "text/turtle"; - case NONE: - return null; - default: - return null; - } - } - - static public org.hl7.fhir.dstu3.model.TestScript.ContentType convertContentType(String src) throws FHIRException { - if (src == null) - return null; - if (src.contains("xml")) - return org.hl7.fhir.dstu3.model.TestScript.ContentType.XML; - if (src.contains("json")) - return org.hl7.fhir.dstu3.model.TestScript.ContentType.JSON; - if (src.contains("tu")) - return org.hl7.fhir.dstu3.model.TestScript.ContentType.TTL; - return org.hl7.fhir.dstu3.model.TestScript.ContentType.NONE; - } - - public static org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent(); - copyElement(src, tgt); - if (src.hasField()) - tgt.setFieldElement(convertString(src.getFieldElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent(); - copyElement(src, tgt); - if (src.hasField()) - tgt.setFieldElement(convertString(src.getFieldElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasDirection()) - tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); - if (src.hasCompareToSourceId()) - tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); - if (src.hasCompareToSourceExpression()) - tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); - if (src.hasCompareToSourcePath()) - tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasHeaderField()) - tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); - if (src.hasMinimumId()) - tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); - if (src.hasNavigationLinks()) - tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); - if (src.hasOperator()) - tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasRequestMethod()) - tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); - if (src.hasRequestURL()) - tgt.setRequestURLElement(convertString(src.getRequestURLElement())); - if (src.hasResource()) - tgt.setResource(org.hl7.fhir.r5.model.TestScript.FHIRDefinedType.fromCode(src.getResource())); - if (src.hasResponse()) - tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); - if (src.hasResponseCode()) - tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasValidateProfileId()) - tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasWarningOnly()) - tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasDirection()) - tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); - if (src.hasCompareToSourceId()) - tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); - if (src.hasCompareToSourceExpression()) - tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); - if (src.hasCompareToSourcePath()) - tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); - if (src.hasContentType()) - tgt.setContentType(convertContentType(src.getContentType())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasHeaderField()) - tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); - if (src.hasMinimumId()) - tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); - if (src.hasNavigationLinks()) - tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); - if (src.hasOperator()) - tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasRequestMethod()) - tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); - if (src.hasRequestURL()) - tgt.setRequestURLElement(convertString(src.getRequestURLElement())); - if (src.hasResource()) - tgt.setResource(src.getResource().toCode()); - if (src.hasResponse()) - tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); - if (src.hasResponseCode()) - tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); - if (src.hasSourceId()) - tgt.setSourceIdElement(convertId(src.getSourceIdElement())); - if (src.hasValidateProfileId()) - tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasWarningOnly()) - tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.AssertionDirectionTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case RESPONSE: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.RESPONSE); - break; - case REQUEST: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.REQUEST); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case RESPONSE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.RESPONSE); - break; - case REQUEST: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.REQUEST); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.AssertionOperatorTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case EQUALS: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.EQUALS); - break; - case NOTEQUALS: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTEQUALS); - break; - case IN: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTIN); - break; - case GREATERTHAN: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.GREATERTHAN); - break; - case LESSTHAN: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.LESSTHAN); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.EMPTY); - break; - case NOTEMPTY: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTEMPTY); - break; - case CONTAINS: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.CONTAINS); - break; - case NOTCONTAINS: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTCONTAINS); - break; - case EVAL: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.EVAL); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorTypeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case EQUALS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EQUALS); - break; - case NOTEQUALS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEQUALS); - break; - case IN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTIN); - break; - case GREATERTHAN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.GREATERTHAN); - break; - case LESSTHAN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.LESSTHAN); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EMPTY); - break; - case NOTEMPTY: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEMPTY); - break; - case CONTAINS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.CONTAINS); - break; - case NOTCONTAINS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTCONTAINS); - break; - case EVAL: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EVAL); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DELETE: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.DELETE); - break; - case GET: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.GET); - break; - case OPTIONS: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.OPTIONS); - break; - case PATCH: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.PATCH); - break; - case POST: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.POST); - break; - case PUT: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.PUT); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case DELETE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.DELETE); - break; - case GET: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.GET); - break; - case OPTIONS: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.OPTIONS); - break; - case PATCH: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PATCH); - break; - case POST: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.POST); - break; - case PUT: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PUT); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.AssertionResponseTypesEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case OKAY: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.OKAY); - break; - case CREATED: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.CREATED); - break; - case NOCONTENT: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NOCONTENT); - break; - case NOTMODIFIED: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NOTMODIFIED); - break; - case BAD: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.BAD); - break; - case FORBIDDEN: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.FORBIDDEN); - break; - case NOTFOUND: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NOTFOUND); - break; - case METHODNOTALLOWED: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); - break; - case CONFLICT: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.CONFLICT); - break; - case GONE: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.GONE); - break; - case PRECONDITIONFAILED: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); - break; - case UNPROCESSABLE: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypesEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case OKAY: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.OKAY); - break; - case CREATED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CREATED); - break; - case NOCONTENT: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOCONTENT); - break; - case NOTMODIFIED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTMODIFIED); - break; - case BAD: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.BAD); - break; - case FORBIDDEN: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.FORBIDDEN); - break; - case NOTFOUND: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTFOUND); - break; - case METHODNOTALLOWED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); - break; - case CONFLICT: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CONFLICT); - break; - case GONE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.GONE); - break; - case PRECONDITIONFAILED: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); - break; - case UNPROCESSABLE: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); - break; - default: - tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestScript.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r5.model.TestScript.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.r5.model.TestScript.TestActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - if (src.hasAssert()) - tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); - return tgt; - } - - public static org.hl7.fhir.r5.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r5.model.TestScript.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - public static org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r5.model.TestScript.TeardownActionComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent(); - copyElement(src, tgt); - if (src.hasOperation()) - tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertFilterOperator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FilterOperatorEnumFactory()); - VersionConvertor_30_50.copyElement(src, tgt); - switch(src.getValue()) { - case EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.EQUAL); - break; - case ISA: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.ISA); - break; - case DESCENDENTOF: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.DESCENDENTOF); - break; - case ISNOTA: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.ISNOTA); - break; - case REGEX: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.REGEX); - break; - case IN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.IN); - break; - case NOTIN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NOTIN); - break; - case GENERALIZES: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.GENERALIZES); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.EXISTS); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, boolean nullOk) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.dstu3.model.Parameters) - return Parameters30_50.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); - if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition) - return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance) - return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Appointment) - return Appointment30_50.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); - if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) - return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) - return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.dstu3.model.Basic) - return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); - if (src instanceof org.hl7.fhir.dstu3.model.Binary) - return Binary30_50.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); - if (src instanceof org.hl7.fhir.dstu3.model.BodySite) - return BodySite30_50.convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src); - if (src instanceof org.hl7.fhir.dstu3.model.Bundle) - return Bundle30_50.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); - if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) - return CapabilityStatement30_50.convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) - return CarePlan30_50.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); - if (src instanceof org.hl7.fhir.dstu3.model.CareTeam) - return CareTeam30_50.convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src); - if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) - return ClinicalImpression30_50.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) - return CodeSystem30_50.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.Communication) - return Communication30_50.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); - if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) - return CompartmentDefinition30_50.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Composition) - return Composition30_50.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); - if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) - return ConceptMap30_50.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.dstu3.model.Condition) - return Condition30_50.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Consent) - return Consent30_50.convertConsent((org.hl7.fhir.dstu3.model.Consent) src); - if (src instanceof org.hl7.fhir.dstu3.model.DataElement) - return DataElement30_50.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) - return DetectedIssue30_50.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) - return DeviceUseStatement30_50.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) - return DiagnosticReport30_50.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) - return DocumentReference30_50.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.dstu3.model.Encounter) - return Encounter30_50.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); - if (src instanceof org.hl7.fhir.dstu3.model.Endpoint) - return Endpoint30_50.convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src); - if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) - return EpisodeOfCare30_50.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile) - return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src); - if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) - return FamilyMemberHistory30_50.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.dstu3.model.Flag) - return Flag30_50.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); - if (src instanceof org.hl7.fhir.dstu3.model.Goal) - return Goal30_50.convertGoal((org.hl7.fhir.dstu3.model.Goal) src); - if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition) - return GraphDefinition30_50.convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Group) - return Group30_50.convertGroup((org.hl7.fhir.dstu3.model.Group) src); - if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) - return HealthcareService30_50.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) - return ImagingStudy30_50.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.dstu3.model.Immunization) - return Immunization30_50.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); - if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) - return ImplementationGuide30_50.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.dstu3.model.Library) - return Library30_50.convertLibrary((org.hl7.fhir.dstu3.model.Library) src); - if (src instanceof org.hl7.fhir.dstu3.model.Linkage) - return Linkage30_50.convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src); - if (src instanceof org.hl7.fhir.dstu3.model.ListResource) - return List30_50.convertList((org.hl7.fhir.dstu3.model.ListResource) src); - if (src instanceof org.hl7.fhir.dstu3.model.Location) - return Location30_50.convertLocation((org.hl7.fhir.dstu3.model.Location) src); - if (src instanceof org.hl7.fhir.dstu3.model.Measure) - return Measure30_50.convertMeasure((org.hl7.fhir.dstu3.model.Measure) src); - if (src instanceof org.hl7.fhir.dstu3.model.Media) - return Media30_50.convertMedia((org.hl7.fhir.dstu3.model.Media) src); - if (src instanceof org.hl7.fhir.dstu3.model.Medication) - return Medication30_50.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration) - return MedicationAdministration30_50.convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) - return MedicationDispense30_50.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest) - return MedicationRequest30_50.convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src); - if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) - return MedicationStatement30_50.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition) - return MessageDefinition30_50.convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) - return MessageHeader30_50.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) - return NamingSystem30_50.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.dstu3.model.Observation) - return Observation30_50.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) - return OperationDefinition30_50.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) - return OperationOutcome30_50.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.dstu3.model.Organization) - return Organization30_50.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); - if (src instanceof org.hl7.fhir.dstu3.model.Patient) - return Patient30_50.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); - if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice) - return PaymentNotice30_50.convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src); - if (src instanceof org.hl7.fhir.dstu3.model.Person) - return Person30_50.convertPerson((org.hl7.fhir.dstu3.model.Person) src); - if (src instanceof org.hl7.fhir.dstu3.model.PlanDefinition) - return PlanDefinition30_50.convertPlanDefinition((org.hl7.fhir.dstu3.model.PlanDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) - return Practitioner30_50.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); - if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole) - return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src); - if (src instanceof org.hl7.fhir.dstu3.model.Provenance) - return Provenance30_50.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); - if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) - return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) - return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) - return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) - return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.dstu3.model.Schedule) - return Schedule30_50.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); - if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) - return SearchParameter30_50.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.dstu3.model.Sequence) - return Sequence30_50.convertSequence((org.hl7.fhir.dstu3.model.Sequence) src); - if (src instanceof org.hl7.fhir.dstu3.model.Slot) - return Slot30_50.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); - if (src instanceof org.hl7.fhir.dstu3.model.Specimen) - return Specimen30_50.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); - if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) - return StructureDefinition30_50.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.dstu3.model.StructureMap) - return StructureMap30_50.convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src); - if (src instanceof org.hl7.fhir.dstu3.model.Substance) - return Substance30_50.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); - if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) - return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.dstu3.model.TestReport) - return TestReport30_50.convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src); - if (src instanceof org.hl7.fhir.dstu3.model.TestScript) - return TestScript30_50.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); - if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) - return ValueSet30_50.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); - if (!nullOk) - throw new FHIRException("Unknown resource " + src.fhirType()); - else - return null; - } - - public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, boolean nullOk) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r5.model.Parameters) { - if (((org.hl7.fhir.r5.model.Parameters) src).hasParameter("profile-url")) - return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.r5.model.Parameters) src); - else - return Parameters30_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); - } - if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition) - return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance) - return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.r5.model.Appointment) - return Appointment30_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); - if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) - return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.r5.model.AuditEvent) - return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.r5.model.Basic) - return Basic30_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); - if (src instanceof org.hl7.fhir.r5.model.Binary) - return Binary30_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); - if (src instanceof org.hl7.fhir.r5.model.BodyStructure) - return BodySite30_50.convertBodySite((org.hl7.fhir.r5.model.BodyStructure) src); - if (src instanceof org.hl7.fhir.r5.model.Bundle) - return Bundle30_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src); - if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) - return CapabilityStatement30_50.convertCapabilityStatement((org.hl7.fhir.r5.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r5.model.CarePlan) - return CarePlan30_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); - if (src instanceof org.hl7.fhir.r5.model.CareTeam) - return CareTeam30_50.convertCareTeam((org.hl7.fhir.r5.model.CareTeam) src); - if (src instanceof org.hl7.fhir.r5.model.ClinicalImpression) - return ClinicalImpression30_50.convertClinicalImpression((org.hl7.fhir.r5.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.r5.model.CodeSystem) - return CodeSystem30_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.r5.model.Communication) - return Communication30_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); - if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition) - return CompartmentDefinition30_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Composition) - return Composition30_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); - if (src instanceof org.hl7.fhir.r5.model.ConceptMap) - return ConceptMap30_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r5.model.Condition) - return Condition30_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); - if (src instanceof org.hl7.fhir.r5.model.Consent) - return Consent30_50.convertConsent((org.hl7.fhir.r5.model.Consent) src); - if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) - return DetectedIssue30_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceUseStatement) - return DeviceUseStatement30_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) - return DiagnosticReport30_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.r5.model.DocumentReference) - return DocumentReference30_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r5.model.Encounter) - return Encounter30_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); - if (src instanceof org.hl7.fhir.r5.model.Endpoint) - return Endpoint30_50.convertEndpoint((org.hl7.fhir.r5.model.Endpoint) src); - if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) - return EpisodeOfCare30_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) - return FamilyMemberHistory30_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.r5.model.Flag) - return Flag30_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); - if (src instanceof org.hl7.fhir.r5.model.Goal) - return Goal30_50.convertGoal((org.hl7.fhir.r5.model.Goal) src); - if (src instanceof org.hl7.fhir.r5.model.GraphDefinition) - return GraphDefinition30_50.convertGraphDefinition((org.hl7.fhir.r5.model.GraphDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Group) - return Group30_50.convertGroup((org.hl7.fhir.r5.model.Group) src); - if (src instanceof org.hl7.fhir.r5.model.HealthcareService) - return HealthcareService30_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.r5.model.ImagingStudy) - return ImagingStudy30_50.convertImagingStudy((org.hl7.fhir.r5.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.r5.model.Immunization) - return Immunization30_50.convertImmunization((org.hl7.fhir.r5.model.Immunization) src); - if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) - return ImplementationGuide30_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r5.model.Library) - return Library30_50.convertLibrary((org.hl7.fhir.r5.model.Library) src); - if (src instanceof org.hl7.fhir.r5.model.Linkage) - return Linkage30_50.convertLinkage((org.hl7.fhir.r5.model.Linkage) src); - if (src instanceof org.hl7.fhir.r5.model.ListResource) - return List30_50.convertList((org.hl7.fhir.r5.model.ListResource) src); - if (src instanceof org.hl7.fhir.r5.model.Location) - return Location30_50.convertLocation((org.hl7.fhir.r5.model.Location) src); - if (src instanceof org.hl7.fhir.r5.model.Measure) - return Measure30_50.convertMeasure((org.hl7.fhir.r5.model.Measure) src); - if (src instanceof org.hl7.fhir.r5.model.DocumentReference) - return Media30_50.convertMedia((org.hl7.fhir.r5.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r5.model.Medication) - return Medication30_50.convertMedication((org.hl7.fhir.r5.model.Medication) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationAdministration) - return MedicationAdministration30_50.convertMedicationAdministration((org.hl7.fhir.r5.model.MedicationAdministration) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) - return MedicationDispense30_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationRequest) - return MedicationRequest30_50.convertMedicationRequest((org.hl7.fhir.r5.model.MedicationRequest) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationUsage) - return MedicationStatement30_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationUsage) src); - if (src instanceof org.hl7.fhir.r5.model.MessageDefinition) - return MessageDefinition30_50.convertMessageDefinition((org.hl7.fhir.r5.model.MessageDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.MessageHeader) - return MessageHeader30_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.r5.model.NamingSystem) - return NamingSystem30_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r5.model.Observation) - return Observation30_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); - if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) - return OperationDefinition30_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) - return OperationOutcome30_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r5.model.Organization) - return Organization30_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); - if (src instanceof org.hl7.fhir.r5.model.Patient) - return Patient30_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); - if (src instanceof org.hl7.fhir.r5.model.PaymentNotice) - return PaymentNotice30_50.convertPaymentNotice((org.hl7.fhir.r5.model.PaymentNotice) src); - if (src instanceof org.hl7.fhir.r5.model.Person) - return Person30_50.convertPerson((org.hl7.fhir.r5.model.Person) src); - if (src instanceof org.hl7.fhir.r5.model.PlanDefinition) - return PlanDefinition30_50.convertPlanDefinition((org.hl7.fhir.r5.model.PlanDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Practitioner) - return Practitioner30_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); - if (src instanceof org.hl7.fhir.r5.model.PractitionerRole) - return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src); - if (src instanceof org.hl7.fhir.r5.model.Provenance) - return Provenance30_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); - if (src instanceof org.hl7.fhir.r5.model.Questionnaire) - return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) - return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r5.model.RelatedPerson) - return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) - return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.r5.model.Schedule) - return Schedule30_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); - if (src instanceof org.hl7.fhir.r5.model.SearchParameter) - return SearchParameter30_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r5.model.MolecularSequence) - return Sequence30_50.convertSequence((org.hl7.fhir.r5.model.MolecularSequence) src); - if (src instanceof org.hl7.fhir.r5.model.Slot) - return Slot30_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); - if (src instanceof org.hl7.fhir.r5.model.Specimen) - return Specimen30_50.convertSpecimen((org.hl7.fhir.r5.model.Specimen) src); - if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) - return StructureDefinition30_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.StructureMap) - return StructureMap30_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src); - if (src instanceof org.hl7.fhir.r5.model.Substance) - return Substance30_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); - if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) - return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.r5.model.TestReport) - return TestReport30_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); - if (src instanceof org.hl7.fhir.r5.model.TestScript) - return TestScript30_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); - if (src instanceof org.hl7.fhir.r5.model.ValueSet) - return ValueSet30_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); - if (!nullOk) - throw new FHIRException("Unknown resource " + src.fhirType()); - else - return null; - } - - public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src, boolean b) { - TerminologyCapabilities res = new TerminologyCapabilities(); - for (ParametersParameterComponent p : src.getParameter()) { - if (p.getName().equals("system")) - res.addCodeSystem().setUri(p.getValue().primitiveValue()); - if (p.getName().equals("expansion.parameter")) - res.getExpansion().addParameter().setName(p.getValue().primitiveValue()); - } - return res; - } - - public static boolean convertsResource(String rt) { - return Utilities.existsInList(rt, "Parameters", "ActivityDefinition", "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodyStructure", "Bundle", "CapabilityStatement", "CarePlan", "CareTeam", "ClinicalImpression", "CodeSystem", "Communication", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Consent", "DetectedIssue", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "Endpoint", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Goal", "GraphDefinition", "Group", "HealthcareService", "ImagingStudy", "Immunization", "ImplementationGuide", "Library", "Linkage", "ListResource", "Location", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationRequest", "MedicationStatement", "MessageDefinition", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "PaymentNotice", "Person", "PlanDefinition", "Practitioner", "PractitionerRole", "ProcessRequest", "Questionnaire", "QuestionnaireResponse", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "Slot", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "TestReport", "TestScript", "ValueSet"); - } + tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); + } + } else { + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertBindingStrength(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertBindingStrength(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.BindingStrengthEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + } else { + switch (src.getValue()) { + case REQUIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.REQUIRED); + break; + case EXTENSIBLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXTENSIBLE); + break; + case PREFERRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.PREFERRED); + break; + case EXAMPLE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.EXAMPLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.BindingStrength.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentity()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMap()) tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasComment()) tgt.setCommentElement(convertString(src.getCommentElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentity()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMap()) tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasComment()) tgt.setCommentElement(convertString(src.getCommentElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.setFamilyElement(convertString(src.getFamilyElement())); + for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.setFamilyElement(convertString(src.getFamilyElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue()); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.dstu3.model.ParameterDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ParameterDefinition tgt = new org.hl7.fhir.r5.model.ParameterDefinition(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertCode(src.getNameElement())); + if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); + if (src.hasMin()) tgt.setMinElement(convertInteger(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasDocumentation()) tgt.setDocumentationElement(convertString(src.getDocumentationElement())); + if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); + if (src.hasProfile()) { + tgt.setProfile(convertReference(src.getProfile()).getReference()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.ParameterDefinition tgt = new org.hl7.fhir.dstu3.model.ParameterDefinition(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertCode(src.getNameElement())); + if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); + if (src.hasMin()) tgt.setMinElement(convertInteger(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasDocumentation()) tgt.setDocumentationElement(convertString(src.getDocumentationElement())); + if (src.hasType()) tgt.setType(src.getType().toCode()); + if (src.hasProfile()) tgt.setProfile(new org.hl7.fhir.dstu3.model.Reference(src.getProfile())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertParameterUse(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.OperationParameterUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); + } else { + switch (src.getValue()) { + case IN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.IN); + break; + case OUT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.OUT); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertParameterUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUseEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL); + } else { + switch (src.getValue()) { + case IN: + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.IN); + break; + case OUT: + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.OUT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.ParameterDefinition.ParameterUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.RelatedArtifact tgt = new org.hl7.fhir.r5.model.RelatedArtifact(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasCitation()) tgt.setCitation(src.getCitation()); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasDocument()) tgt.setDocument(convertAttachment(src.getDocument())); + if (src.hasResource()) tgt.setResourceElement(convertReferenceToCanonical(src.getResource())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.RelatedArtifact tgt = new org.hl7.fhir.dstu3.model.RelatedArtifact(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasCitation()) tgt.setCitation(src.getCitation()); + if (src.hasUrl()) tgt.setUrl(src.getUrl()); + if (src.hasDocument()) tgt.setDocument(convertAttachment(src.getDocument())); + if (src.hasResource()) tgt.setResource(convertCanonicalToReference(src.getResourceElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); + } else { + switch (src.getValue()) { + case DOCUMENTATION: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); + break; + case JUSTIFICATION: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); + break; + case CITATION: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.CITATION); + break; + case PREDECESSOR: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); + break; + case SUCCESSOR: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); + break; + case DERIVEDFROM: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); + break; + case DEPENDSON: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + break; + case COMPOSEDOF: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); + } else { + switch (src.getValue()) { + case DOCUMENTATION: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); + break; + case JUSTIFICATION: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); + break; + case CITATION: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.CITATION); + break; + case PREDECESSOR: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); + break; + case SUCCESSOR: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); + break; + case DERIVEDFROM: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); + break; + case DEPENDSON: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + break; + case COMPOSEDOF: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.RelatedArtifact.RelatedArtifactType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_50::convertDayOfWeek).collect(Collectors.toList())); + tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList())); + for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCount(src.getCount()); + if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); + if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_50::convertDayOfWeek).collect(Collectors.toList())); + tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList())); + for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertDayOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertDayOfWeek(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.DayOfWeekEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case MORN: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN); + break; + case AFT: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT); + break; + case EVE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE); + break; + case NIGHT: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NIGHT); + break; + case PHS: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PHS); + break; + case HS: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case MORN: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.MORN); + break; + case AFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AFT); + break; + case EVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.EVE); + break; + case NIGHT: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NIGHT); + break; + case PHS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PHS); + break; + case HS: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.UsageContext convertUsageContext(org.hl7.fhir.dstu3.model.UsageContext src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.UsageContext tgt = new org.hl7.fhir.r5.model.UsageContext(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(convertCoding(src.getCode())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.UsageContext convertUsageContext(org.hl7.fhir.r5.model.UsageContext src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.UsageContext tgt = new org.hl7.fhir.dstu3.model.UsageContext(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(convertCoding(src.getCode())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.SimpleQuantity tgt = new org.hl7.fhir.r5.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.SimpleQuantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.SimpleQuantity tgt = new org.hl7.fhir.dstu3.model.SimpleQuantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.dstu3.model.TriggerDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TriggerDefinition tgt = new org.hl7.fhir.r5.model.TriggerDefinition(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertTriggerType(src.getTypeElement())); + if (src.hasEventName()) tgt.setNameElement(convertString(src.getEventNameElement())); + if (src.hasEventTiming()) tgt.setTiming(convertType(src.getEventTiming())); + if (src.hasEventData()) tgt.addData(convertDataRequirement(src.getEventData())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r5.model.TriggerDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TriggerDefinition tgt = new org.hl7.fhir.dstu3.model.TriggerDefinition(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertTriggerType(src.getTypeElement())); + if (src.hasName()) tgt.setEventNameElement(convertString(src.getNameElement())); + if (src.hasTiming()) tgt.setEventTiming(convertType(src.getTiming())); + if (src.hasData()) tgt.setEventData(convertDataRequirement(src.getDataFirstRep())); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement convertDataRequirement(org.hl7.fhir.dstu3.model.DataRequirement src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement tgt = new org.hl7.fhir.r5.model.DataRequirement(); + copyElement(src, tgt, VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME); + if (src.hasType()) { + if (src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { + tgt.setType(Enumerations.FHIRAllTypes.fromCode(src.getExtensionString(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME))); + } else { + String n = VersionConvertorResourceNameMapper.mapName3to5(src.getType()); + if (n != null) { + tgt.setType(Enumerations.FHIRAllTypes.fromCode(n)); + } + tgt.addExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME, new org.hl7.fhir.r5.model.CodeType(src.getType())); + } + } + for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.dstu3.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); + for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) + tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); + for (org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) + tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DataRequirement convertDataRequirement(org.hl7.fhir.r5.model.DataRequirement src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DataRequirement tgt = new org.hl7.fhir.dstu3.model.DataRequirement(); + copyElement(src, tgt, VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME); + if (src.hasType() || src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { + if (src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { + tgt.setType(src.getExtensionString(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)); + } else { + String n = VersionConvertorResourceNameMapper.mapName5to3(src.getType().toCode()); + if (n != null) { + tgt.setType(n); + } + tgt.addExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME, new org.hl7.fhir.dstu3.model.CodeType(src.getType().toCode())); + } + } + for (org.hl7.fhir.r5.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); + for (org.hl7.fhir.r5.model.StringType t : src.getMustSupport()) tgt.addMustSupport(t.getValue()); + for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) + tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); + for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) + tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValueSet()) { + DataType t = convertType(src.getValueSet()); + if (t instanceof org.hl7.fhir.r5.model.Reference) + tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference()); + else tgt.setValueSet(t.primitiveValue()); + tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); + } + for (org.hl7.fhir.dstu3.model.CodeType t : src.getValueCode()) tgt.addCode(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.Coding t : src.getValueCoding()) tgt.addCode(convertCoding(t)); + for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getValueCodeableConcept()) tgt.addCode(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementCodeFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValueSet()) { + String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); + if (vsr != null) tgt.setValueSet(new org.hl7.fhir.dstu3.model.UriType(vsr)); + else tgt.setValueSet(new org.hl7.fhir.dstu3.model.Reference(src.getValueSet())); + } + for (org.hl7.fhir.r5.model.Coding t : src.getCode()) { + tgt.addValueCoding(convertCoding(t)); + } + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.dstu3.model.DataRequirement.DataRequirementDateFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertTriggerType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TriggerDefinition.TriggerTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NULL); + } else { + switch (src.getValue()) { + case NAMEDEVENT: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NAMEDEVENT); + break; + case PERIODIC: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.PERIODIC); + break; + case DATAADDED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAADDED); + break; + case DATAMODIFIED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAMODIFIED); + break; + case DATAREMOVED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAREMOVED); + break; + case DATAACCESSED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSED); + break; + case DATAACCESSENDED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSENDED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertTriggerType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NULL); + } else { + switch (src.getValue()) { + case NAMEDEVENT: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NAMEDEVENT); + break; + case PERIODIC: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.PERIODIC); + break; + case DATAADDED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAADDED); + break; + case DATAMODIFIED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAMODIFIED); + break; + case DATAREMOVED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAREMOVED); + break; + case DATAACCESSED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSED); + break; + case DATAACCESSENDED: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.DATAACCESSENDED); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TriggerDefinition.TriggerType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.dstu3.model.Type src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.dstu3.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.dstu3.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.dstu3.model.BooleanType) + return convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeType) return convertCode((org.hl7.fhir.dstu3.model.CodeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateType) return convertDate((org.hl7.fhir.dstu3.model.DateType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DateTimeType) + return convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.DecimalType) + return convertDecimal((org.hl7.fhir.dstu3.model.DecimalType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IdType) return convertId((org.hl7.fhir.dstu3.model.IdType) src); + if (src instanceof org.hl7.fhir.dstu3.model.InstantType) + return convertInstant((org.hl7.fhir.dstu3.model.InstantType) src); + if (src instanceof org.hl7.fhir.dstu3.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.dstu3.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.dstu3.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.dstu3.model.IntegerType) + return convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src); + if (src instanceof org.hl7.fhir.dstu3.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.dstu3.model.OidType) return convertOid((org.hl7.fhir.dstu3.model.OidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.StringType) + return convertString((org.hl7.fhir.dstu3.model.StringType) src); + if (src instanceof org.hl7.fhir.dstu3.model.TimeType) return convertTime((org.hl7.fhir.dstu3.model.TimeType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UriType) return convertUri((org.hl7.fhir.dstu3.model.UriType) src); + if (src instanceof org.hl7.fhir.dstu3.model.UuidType) return convertUuid((org.hl7.fhir.dstu3.model.UuidType) src); + if (src instanceof org.hl7.fhir.dstu3.model.Extension) + return convertExtension((org.hl7.fhir.dstu3.model.Extension) src); + if (src instanceof org.hl7.fhir.dstu3.model.Narrative) + return convertNarrative((org.hl7.fhir.dstu3.model.Narrative) src); + if (src instanceof org.hl7.fhir.dstu3.model.Age) return convertAge((org.hl7.fhir.dstu3.model.Age) src); + if (src instanceof org.hl7.fhir.dstu3.model.Annotation) + return convertAnnotation((org.hl7.fhir.dstu3.model.Annotation) src); + if (src instanceof org.hl7.fhir.dstu3.model.Attachment) + return convertAttachment((org.hl7.fhir.dstu3.model.Attachment) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.dstu3.model.Coding) return convertCoding((org.hl7.fhir.dstu3.model.Coding) src); + if (src instanceof org.hl7.fhir.dstu3.model.Count) return convertCount((org.hl7.fhir.dstu3.model.Count) src); + if (src instanceof org.hl7.fhir.dstu3.model.Distance) + return convertDistance((org.hl7.fhir.dstu3.model.Distance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Duration) + return convertDuration((org.hl7.fhir.dstu3.model.Duration) src); + if (src instanceof org.hl7.fhir.dstu3.model.Identifier) + return convertIdentifier((org.hl7.fhir.dstu3.model.Identifier) src); + if (src instanceof org.hl7.fhir.dstu3.model.Money) return convertMoney((org.hl7.fhir.dstu3.model.Money) src); + if (src instanceof org.hl7.fhir.dstu3.model.Period) return convertPeriod((org.hl7.fhir.dstu3.model.Period) src); + if (src instanceof org.hl7.fhir.dstu3.model.Quantity) + return convertQuantity((org.hl7.fhir.dstu3.model.Quantity) src); + if (src instanceof org.hl7.fhir.dstu3.model.Range) return convertRange((org.hl7.fhir.dstu3.model.Range) src); + if (src instanceof org.hl7.fhir.dstu3.model.Ratio) return convertRatio((org.hl7.fhir.dstu3.model.Ratio) src); + if (src instanceof org.hl7.fhir.dstu3.model.Reference) + return convertReference((org.hl7.fhir.dstu3.model.Reference) src); + if (src instanceof org.hl7.fhir.dstu3.model.SampledData) + return convertSampledData((org.hl7.fhir.dstu3.model.SampledData) src); + if (src instanceof org.hl7.fhir.dstu3.model.Signature) + return convertSignature((org.hl7.fhir.dstu3.model.Signature) src); + if (src instanceof org.hl7.fhir.dstu3.model.Address) return convertAddress((org.hl7.fhir.dstu3.model.Address) src); + if (src instanceof org.hl7.fhir.dstu3.model.ContactDetail) + return convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) src); + if (src instanceof org.hl7.fhir.dstu3.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.dstu3.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.dstu3.model.Contributor) + return convertContributor((org.hl7.fhir.dstu3.model.Contributor) src); + if (src instanceof org.hl7.fhir.dstu3.model.Dosage) return convertDosage((org.hl7.fhir.dstu3.model.Dosage) src); + if (src instanceof org.hl7.fhir.dstu3.model.HumanName) + return convertHumanName((org.hl7.fhir.dstu3.model.HumanName) src); + if (src instanceof org.hl7.fhir.dstu3.model.Meta) return convertMeta((org.hl7.fhir.dstu3.model.Meta) src); + if (src instanceof org.hl7.fhir.dstu3.model.ParameterDefinition) + return convertParameterDefinition((org.hl7.fhir.dstu3.model.ParameterDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.RelatedArtifact) + return convertRelatedArtifact((org.hl7.fhir.dstu3.model.RelatedArtifact) src); + if (src instanceof org.hl7.fhir.dstu3.model.Timing) return convertTiming((org.hl7.fhir.dstu3.model.Timing) src); + if (src instanceof org.hl7.fhir.dstu3.model.UsageContext) + return convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) src); + if (src instanceof org.hl7.fhir.dstu3.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.dstu3.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.DataRequirement) + return convertDataRequirement((org.hl7.fhir.dstu3.model.DataRequirement) src); + if (src instanceof org.hl7.fhir.dstu3.model.TriggerDefinition) + return convertTriggerDefinition((org.hl7.fhir.dstu3.model.TriggerDefinition) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.dstu3.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r5.model.BooleanType) + return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r5.model.CodeType) return convertCode((org.hl7.fhir.r5.model.CodeType) src); + if (src instanceof org.hl7.fhir.r5.model.DateType) return convertDate((org.hl7.fhir.r5.model.DateType) src); + if (src instanceof org.hl7.fhir.r5.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r5.model.DecimalType) + return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r5.model.IdType) return convertId((org.hl7.fhir.r5.model.IdType) src); + if (src instanceof org.hl7.fhir.r5.model.InstantType) + return convertInstant((org.hl7.fhir.r5.model.InstantType) src); + if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r5.model.Integer64Type) + return convertInteger64((org.hl7.fhir.r5.model.Integer64Type) src); + if (src instanceof org.hl7.fhir.r5.model.IntegerType) + return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r5.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r5.model.OidType) return convertOid((org.hl7.fhir.r5.model.OidType) src); + if (src instanceof org.hl7.fhir.r5.model.StringType) return convertString((org.hl7.fhir.r5.model.StringType) src); + if (src instanceof org.hl7.fhir.r5.model.TimeType) return convertTime((org.hl7.fhir.r5.model.TimeType) src); + if (src instanceof org.hl7.fhir.r5.model.UriType) return convertUri((org.hl7.fhir.r5.model.UriType) src); + if (src instanceof org.hl7.fhir.r5.model.UuidType) return convertUuid((org.hl7.fhir.r5.model.UuidType) src); + if (src instanceof org.hl7.fhir.r5.model.Extension) return convertExtension((org.hl7.fhir.r5.model.Extension) src); + if (src instanceof org.hl7.fhir.r5.model.Narrative) return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); + if (src instanceof org.hl7.fhir.r5.model.Age) return convertAge((org.hl7.fhir.r5.model.Age) src); + if (src instanceof org.hl7.fhir.r5.model.Annotation) + return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); + if (src instanceof org.hl7.fhir.r5.model.Attachment) + return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); + if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r5.model.Coding) return convertCoding((org.hl7.fhir.r5.model.Coding) src); + if (src instanceof org.hl7.fhir.r5.model.Count) return convertCount((org.hl7.fhir.r5.model.Count) src); + if (src instanceof org.hl7.fhir.r5.model.Distance) return convertDistance((org.hl7.fhir.r5.model.Distance) src); + if (src instanceof org.hl7.fhir.r5.model.Duration) return convertDuration((org.hl7.fhir.r5.model.Duration) src); + if (src instanceof org.hl7.fhir.r5.model.Identifier) + return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); + if (src instanceof org.hl7.fhir.r5.model.Money) return convertMoney((org.hl7.fhir.r5.model.Money) src); + if (src instanceof org.hl7.fhir.r5.model.Period) return convertPeriod((org.hl7.fhir.r5.model.Period) src); + if (src instanceof org.hl7.fhir.r5.model.Quantity) return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); + if (src instanceof org.hl7.fhir.r5.model.Range) return convertRange((org.hl7.fhir.r5.model.Range) src); + if (src instanceof org.hl7.fhir.r5.model.Ratio) return convertRatio((org.hl7.fhir.r5.model.Ratio) src); + if (src instanceof org.hl7.fhir.r5.model.Reference) return convertReference((org.hl7.fhir.r5.model.Reference) src); + if (src instanceof org.hl7.fhir.r5.model.SampledData) + return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); + if (src instanceof org.hl7.fhir.r5.model.Signature) return convertSignature((org.hl7.fhir.r5.model.Signature) src); + if (src instanceof org.hl7.fhir.r5.model.Address) return convertAddress((org.hl7.fhir.r5.model.Address) src); + if (src instanceof org.hl7.fhir.r5.model.ContactDetail) + return convertContactDetail((org.hl7.fhir.r5.model.ContactDetail) src); + if (src instanceof org.hl7.fhir.r5.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r5.model.Contributor) + return convertContributor((org.hl7.fhir.r5.model.Contributor) src); + if (src instanceof org.hl7.fhir.r5.model.Dosage) return convertDosage((org.hl7.fhir.r5.model.Dosage) src); + if (src instanceof org.hl7.fhir.r5.model.HumanName) return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); + if (src instanceof org.hl7.fhir.r5.model.Meta) return convertMeta((org.hl7.fhir.r5.model.Meta) src); + if (src instanceof org.hl7.fhir.r5.model.ParameterDefinition) + return convertParameterDefinition((org.hl7.fhir.r5.model.ParameterDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.RelatedArtifact) + return convertRelatedArtifact((org.hl7.fhir.r5.model.RelatedArtifact) src); + if (src instanceof org.hl7.fhir.r5.model.Timing) return convertTiming((org.hl7.fhir.r5.model.Timing) src); + if (src instanceof org.hl7.fhir.r5.model.UsageContext) + return convertUsageContext((org.hl7.fhir.r5.model.UsageContext) src); + if (src instanceof org.hl7.fhir.r5.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.r5.model.ElementDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.DataRequirement) + return convertDataRequirement((org.hl7.fhir.r5.model.DataRequirement) src); + if (src instanceof org.hl7.fhir.r5.model.TriggerDefinition) + return convertTriggerDefinition((org.hl7.fhir.r5.model.TriggerDefinition) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + static public void copyDomainResource(org.hl7.fhir.dstu3.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.dstu3.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); + for (org.hl7.fhir.dstu3.model.Extension t2 : src.getExtension()) { + if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); + } + for (org.hl7.fhir.dstu3.model.Extension t3 : src.getModifierExtension()) { + if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); + } + } + + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; + } + + static public void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.dstu3.model.DomainResource tgt, String... extensionsToIgnore) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r5.model.Resource t1 : src.getContained()) tgt.addContained(convertResource(t1, false)); + for (org.hl7.fhir.r5.model.Extension t2 : src.getExtension()) { + if (!isExemptExtension(t2.getUrl(), extensionsToIgnore)) tgt.addExtension(convertExtension(t2)); + } + for (org.hl7.fhir.r5.model.Extension t3 : src.getModifierExtension()) { + if (!isExemptExtension(t3.getUrl(), extensionsToIgnore)) tgt.addModifierExtension(convertExtension(t3)); + } + } + + static public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setIdElement(convertId(src.getIdElement())); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + } + + static public void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setIdElement(convertId(src.getIdElement())); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + } + + static public org.hl7.fhir.r5.model.Enumeration convertPublicationStatus(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.RETIRED); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertPublicationStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + } else { + switch (src.getValue()) { + case DRAFT: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.DRAFT); + break; + case ACTIVE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + break; + case RETIRED: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.RETIRED); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.NULL); + break; + } + } + return tgt; + } + + static public CodeableReference convertReferenceToCodableReference(org.hl7.fhir.dstu3.model.Reference src) { + CodeableReference tgt = new CodeableReference(); + tgt.setReference(convertReference(src)); + return tgt; + } + + static public CodeableReference convertCodeableConceptToCodableReference(org.hl7.fhir.dstu3.model.CodeableConcept src) { + CodeableReference tgt = new CodeableReference(); + tgt.setConcept(convertCodeableConcept(src)); + return tgt; + } + + static public org.hl7.fhir.r5.model.CanonicalType convertReferenceToCanonical(org.hl7.fhir.dstu3.model.Reference src) throws FHIRException { + org.hl7.fhir.r5.model.CanonicalType dst = new org.hl7.fhir.r5.model.CanonicalType(src.getReference()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.dstu3.model.Reference convertCanonicalToReference(org.hl7.fhir.r5.model.CanonicalType src) throws FHIRException { + org.hl7.fhir.dstu3.model.Reference dst = new org.hl7.fhir.dstu3.model.Reference(src.getValue()); + copyElement(src, dst); + return dst; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSearchParamType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertSearchParamType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.SearchParamTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); + } else { + switch (src.getValue()) { + case NUMBER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER); + break; + case DATE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.DATE); + break; + case STRING: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING); + break; + case TOKEN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); + break; + case REFERENCE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE); + break; + case COMPOSITE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.COMPOSITE); + break; + case QUANTITY: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.QUANTITY); + break; + case URI: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.URI); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertFilterOperator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CodeSystem.FilterOperatorEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NULL); + } else { + switch (src.getValue()) { + case EQUAL: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.EQUAL); + break; + case ISA: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.ISA); + break; + case DESCENDENTOF: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.DESCENDENTOF); + break; + case ISNOTA: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.ISNOTA); + break; + case REGEX: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.REGEX); + break; + case IN: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NOTIN); + break; + case GENERALIZES: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.GENERALIZES); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.EXISTS); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.CodeSystem.FilterOperator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent(); + copyElement(src, tgt); + if (src.hasAuthority()) tgt.setAuthorityElement(convertUri(src.getAuthorityElement())); + if (src.hasUri()) tgt.setUriElement(convertUri(src.getUriElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.dstu3.model.Consent.ConsentPolicyComponent(); + copyElement(src, tgt); + if (src.hasAuthority()) tgt.setAuthorityElement(convertUri(src.getAuthorityElement())); + if (src.hasUri()) tgt.setUriElement(convertUri(src.getUriElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConsentDataMeaning(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Consent.ConsentDataMeaningEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.NULL); + } else { + switch (src.getValue()) { + case INSTANCE: + tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.INSTANCE); + break; + case RELATED: + tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.RELATED); + break; + case DEPENDENTS: + tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.DEPENDENTS); + break; + case AUTHOREDBY: + tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.AUTHOREDBY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertConsentDataMeaning(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaningEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.NULL); + } else { + switch (src.getValue()) { + case INSTANCE: + tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.INSTANCE); + break; + case RELATED: + tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.RELATED); + break; + case DEPENDENTS: + tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.DEPENDENTS); + break; + case AUTHOREDBY: + tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.AUTHOREDBY); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Consent.ConsentDataMeaning.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent convertDocumentManifestRelatedComponent(org.hl7.fhir.r5.model.DocumentManifest.DocumentManifestRelatedComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent tgt = new org.hl7.fhir.dstu3.model.DocumentManifest.DocumentManifestRelatedComponent(); + copyElement(src, tgt); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasRef()) tgt.setRef(convertReference(src.getRef())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertDocumentRelationshipType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.NULL); + } else { + switch (src.getValue()) { + case REPLACES: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.REPLACES); + break; + case TRANSFORMS: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.TRANSFORMS); + break; + case SIGNS: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.SIGNS); + break; + case APPENDS: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.APPENDS); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DocumentRelationshipType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.Encounter.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasRole()) tgt.setUse(convertCodeableConcept(src.getRole())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.Encounter.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.Encounter.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasUse()) tgt.setRole(convertCodeableConcept(src.getUse())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasRole()) tgt.setRole(convertCodeableConcept(src.getRole())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent(); + copyElement(src, tgt); + if (src.hasCondition()) tgt.setCondition(convertReference(src.getCondition())); + if (src.hasRole()) tgt.setRole(convertCodeableConcept(src.getRole())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAdministrativeGender(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAdministrativeGender(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGenderEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + } else { + switch (src.getValue()) { + case MALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.MALE); + break; + case FEMALE: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.FEMALE); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.OTHER); + break; + case UNKNOWN: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.NULL); + break; + } + } + return tgt; + } + + private static final String CODE_SYSTEM_MEDIA_TYPE = "http://terminology.hl7.org/CodeSystem/media-type"; + + public static String convertCoding2Uri(org.hl7.fhir.dstu3.model.Coding code) { + return code.getSystem() + "/" + code.getCode(); + } + + public static org.hl7.fhir.dstu3.model.Coding convertUri2Coding(String uri) { + int i = uri.lastIndexOf("/"); + return new org.hl7.fhir.dstu3.model.Coding().setSystem(uri.substring(0, i)).setCode(uri.substring(i + 1)); + } + + static public org.hl7.fhir.r5.model.Enumeration convertDaysOfWeek(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Provenance convertProvenance(org.hl7.fhir.dstu3.model.Provenance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Provenance tgt = new org.hl7.fhir.r5.model.Provenance(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.dstu3.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t)); + if (src.hasPeriod()) tgt.setOccurred(convertPeriod(src.getPeriod())); + if (src.hasRecorded()) tgt.setRecordedElement(convertInstant(src.getRecordedElement())); + for (org.hl7.fhir.dstu3.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue()); + if (src.hasLocation()) tgt.setLocation(convertReference(src.getLocation())); + for (org.hl7.fhir.dstu3.model.Coding t : src.getReason()) tgt.addReason(convertCodingToCodeableConcept(t)); + if (src.hasActivity()) tgt.setActivity(convertCodingToCodeableConcept(src.getActivity())); + for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) + tgt.addAgent(convertProvenanceAgentComponent(t)); + for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) + tgt.addEntity(convertProvenanceEntityComponent(t)); + for (org.hl7.fhir.dstu3.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Provenance convertProvenance(org.hl7.fhir.r5.model.Provenance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Provenance tgt = new org.hl7.fhir.dstu3.model.Provenance(); + copyDomainResource(src, tgt); + for (org.hl7.fhir.r5.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t)); + if (src.hasOccurredPeriod()) tgt.setPeriod(convertPeriod(src.getOccurredPeriod())); + if (src.hasRecorded()) tgt.setRecordedElement(convertInstant(src.getRecordedElement())); + for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue()); + if (src.hasLocation()) tgt.setLocation(convertReference(src.getLocation())); + for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReason()) + for (org.hl7.fhir.r5.model.Coding tc : t.getCoding()) tgt.addReason(convertCoding(tc)); + if (src.hasActivity()) tgt.setActivity(convertCoding(src.getActivity())); + for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) + tgt.addAgent(convertProvenanceAgentComponent(t)); + for (org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) + tgt.addEntity(convertProvenanceEntityComponent(t)); + for (org.hl7.fhir.r5.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t)); + if (src.hasWho()) { + DataType t = convertType(src.getWho()); + if (t instanceof Reference) tgt.setWho((Reference) t); + if (t instanceof UriType) tgt.getWho().setReference(t.primitiveValue()); + } + if (src.hasOnBehalfOf()) { + DataType t = convertType(src.getOnBehalfOf()); + if (t instanceof Reference) tgt.setOnBehalfOf((Reference) t); + if (t instanceof UriType) tgt.getOnBehalfOf().setReference(t.primitiveValue()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t)); + if (src.hasWho()) tgt.setWho(convertType(src.getWho())); + if (src.hasOnBehalfOf()) tgt.setOnBehalfOf(convertType(src.getOnBehalfOf())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent(); + copyElement(src, tgt); + if (src.hasRole()) tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement())); + if (src.hasWhat()) { + DataType t = convertType(src.getWhat()); + if (t instanceof Reference) tgt.setWhat((Reference) t); + else if (t instanceof Identifier) tgt.getWhat().setIdentifier((Identifier) t); + else if (t instanceof UriType) tgt.getWhat().setReference(t.primitiveValue()); + } + for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) + tgt.addAgent(convertProvenanceAgentComponent(t)); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent(); + copyElement(src, tgt); + if (src.hasRole()) tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement())); + if (src.hasWhat()) tgt.setWhat(convertType(src.getWhat())); + for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) + tgt.addAgent(convertProvenanceAgentComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertProvenanceEntityRole(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRoleEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.NULL); + } else { + switch (src.getValue()) { + case DERIVATION: + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.DERIVATION); + break; + case REVISION: + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REVISION); + break; + case QUOTATION: + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.QUOTATION); + break; + case SOURCE: + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.SOURCE); + break; + case REMOVAL: + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REMOVAL); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertProvenanceEntityRole(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRoleEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.NULL); + } else { + switch (src.getValue()) { + case DERIVATION: + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.DERIVATION); + break; + case REVISION: + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REVISION); + break; + case QUOTATION: + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.QUOTATION); + break; + case SOURCE: + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.SOURCE); + break; + case REMOVAL: + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REMOVAL); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.r5.model.TestReport.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r5.model.TestReport.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertUri(src.getDetailElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r5.model.TestReport.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertUri(src.getDetailElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertTestReportActionResult(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestReport.TestReportActionResultEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.NULL); + } else { + switch (src.getValue()) { + case PASS: + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.PASS); + break; + case SKIP: + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.SKIP); + break; + case FAIL: + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.FAIL); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.WARNING); + break; + case ERROR: + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.ERROR); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TestReport.TestReportActionResult.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertTestReportActionResult(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestReport.TestReportActionResultEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL); + } else { + switch (src.getValue()) { + case PASS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.PASS); + break; + case SKIP: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.SKIP); + break; + case FAIL: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.FAIL); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.WARNING); + break; + case ERROR: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.ERROR); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestReport.TestReportActionResult.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertString(src.getDetailElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r5.model.TestReport.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasResult()) tgt.setResultElement(convertTestReportActionResult(src.getResultElement())); + if (src.hasMessage()) tgt.setMessageElement(convertMarkdown(src.getMessageElement())); + if (src.hasDetail()) tgt.setDetailElement(convertString(src.getDetailElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestReport.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.r5.model.TestReport.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.TestActionComponent convertTestActionComponent(org.hl7.fhir.r5.model.TestReport.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.r5.model.TestReport.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r5.model.TestReport.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestReport.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent convertSetupActionComponent(org.hl7.fhir.r5.model.TestScript.SetupActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(convertCoding(src.getType())); + if (src.hasResource()) + tgt.setResource(org.hl7.fhir.r5.model.TestScript.FHIRDefinedType.fromCode(src.getResource())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasAccept()) tgt.setAccept(convertContentType(src.getAccept())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasDestination()) tgt.setDestinationElement(convertInteger(src.getDestinationElement())); + if (src.hasEncodeRequestUrl()) tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); + if (src.hasOrigin()) tgt.setOriginElement(convertInteger(src.getOriginElement())); + if (src.hasParams()) tgt.setParamsElement(convertString(src.getParamsElement())); + for (org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) + tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); + if (src.hasRequestId()) tgt.setRequestIdElement(convertId(src.getRequestIdElement())); + if (src.hasResponseId()) tgt.setResponseIdElement(convertId(src.getResponseIdElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasTargetId()) tgt.setTargetId(src.getTargetId()); + if (src.hasUrl()) tgt.setUrlElement(convertString(src.getUrlElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent convertSetupActionOperationComponent(org.hl7.fhir.r5.model.TestScript.SetupActionOperationComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(convertCoding(src.getType())); + if (src.hasResource()) tgt.setResource(src.getResource().toCode()); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasAccept()) tgt.setAccept(convertContentType(src.getAccept())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasDestination()) tgt.setDestinationElement(convertInteger(src.getDestinationElement())); + if (src.hasEncodeRequestUrl()) tgt.setEncodeRequestUrlElement(convertBoolean(src.getEncodeRequestUrlElement())); + if (src.hasOrigin()) tgt.setOriginElement(convertInteger(src.getOriginElement())); + if (src.hasParams()) tgt.setParamsElement(convertString(src.getParamsElement())); + for (org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent t : src.getRequestHeader()) + tgt.addRequestHeader(convertSetupActionOperationRequestHeaderComponent(t)); + if (src.hasRequestId()) tgt.setRequestIdElement(convertId(src.getRequestIdElement())); + if (src.hasResponseId()) tgt.setResponseIdElement(convertId(src.getResponseIdElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasTargetId()) tgt.setTargetId(src.getTargetId()); + if (src.hasUrl()) tgt.setUrlElement(convertString(src.getUrlElement())); + return tgt; + } + + static public String convertContentType(org.hl7.fhir.dstu3.model.TestScript.ContentType src) throws FHIRException { + if (src == null) return null; + switch (src) { + case XML: + return "application/fhir+xml"; + case JSON: + return "application/fhir+json"; + case TTL: + return "text/turtle"; + case NONE: + return null; + default: + return null; + } + } + + static public org.hl7.fhir.dstu3.model.TestScript.ContentType convertContentType(String src) throws FHIRException { + if (src == null) return null; + if (src.contains("xml")) return org.hl7.fhir.dstu3.model.TestScript.ContentType.XML; + if (src.contains("json")) return org.hl7.fhir.dstu3.model.TestScript.ContentType.JSON; + if (src.contains("tu")) return org.hl7.fhir.dstu3.model.TestScript.ContentType.TTL; + return org.hl7.fhir.dstu3.model.TestScript.ContentType.NONE; + } + + public static org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent(); + copyElement(src, tgt); + if (src.hasField()) tgt.setFieldElement(convertString(src.getFieldElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent convertSetupActionOperationRequestHeaderComponent(org.hl7.fhir.r5.model.TestScript.SetupActionOperationRequestHeaderComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionOperationRequestHeaderComponent(); + copyElement(src, tgt); + if (src.hasField()) tgt.setFieldElement(convertString(src.getFieldElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasDirection()) tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); + if (src.hasCompareToSourceId()) tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); + if (src.hasCompareToSourceExpression()) + tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); + if (src.hasCompareToSourcePath()) + tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasHeaderField()) tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); + if (src.hasMinimumId()) tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); + if (src.hasNavigationLinks()) tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); + if (src.hasOperator()) tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasRequestMethod()) + tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); + if (src.hasRequestURL()) tgt.setRequestURLElement(convertString(src.getRequestURLElement())); + if (src.hasResource()) + tgt.setResource(org.hl7.fhir.r5.model.TestScript.FHIRDefinedType.fromCode(src.getResource())); + if (src.hasResponse()) tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); + if (src.hasResponseCode()) tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasValidateProfileId()) tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasWarningOnly()) tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent convertSetupActionAssertComponent(org.hl7.fhir.r5.model.TestScript.SetupActionAssertComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.SetupActionAssertComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasDirection()) tgt.setDirectionElement(convertAssertionDirectionType(src.getDirectionElement())); + if (src.hasCompareToSourceId()) tgt.setCompareToSourceIdElement(convertString(src.getCompareToSourceIdElement())); + if (src.hasCompareToSourceExpression()) + tgt.setCompareToSourceExpressionElement(convertString(src.getCompareToSourceExpressionElement())); + if (src.hasCompareToSourcePath()) + tgt.setCompareToSourcePathElement(convertString(src.getCompareToSourcePathElement())); + if (src.hasContentType()) tgt.setContentType(convertContentType(src.getContentType())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasHeaderField()) tgt.setHeaderFieldElement(convertString(src.getHeaderFieldElement())); + if (src.hasMinimumId()) tgt.setMinimumIdElement(convertString(src.getMinimumIdElement())); + if (src.hasNavigationLinks()) tgt.setNavigationLinksElement(convertBoolean(src.getNavigationLinksElement())); + if (src.hasOperator()) tgt.setOperatorElement(convertAssertionOperatorType(src.getOperatorElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasRequestMethod()) + tgt.setRequestMethodElement(convertTestScriptRequestMethodCode(src.getRequestMethodElement())); + if (src.hasRequestURL()) tgt.setRequestURLElement(convertString(src.getRequestURLElement())); + if (src.hasResource()) tgt.setResource(src.getResource().toCode()); + if (src.hasResponse()) tgt.setResponseElement(convertAssertionResponseTypes(src.getResponseElement())); + if (src.hasResponseCode()) tgt.setResponseCodeElement(convertString(src.getResponseCodeElement())); + if (src.hasSourceId()) tgt.setSourceIdElement(convertId(src.getSourceIdElement())); + if (src.hasValidateProfileId()) tgt.setValidateProfileIdElement(convertId(src.getValidateProfileIdElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasWarningOnly()) tgt.setWarningOnlyElement(convertBoolean(src.getWarningOnlyElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.AssertionDirectionTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.NULL); + } else { + switch (src.getValue()) { + case RESPONSE: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.RESPONSE); + break; + case REQUEST: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.REQUEST); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionDirectionType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionDirectionType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL); + } else { + switch (src.getValue()) { + case RESPONSE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.RESPONSE); + break; + case REQUEST: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.REQUEST); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionDirectionType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.AssertionOperatorTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NULL); + } else { + switch (src.getValue()) { + case EQUALS: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.EQUALS); + break; + case NOTEQUALS: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTEQUALS); + break; + case IN: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTIN); + break; + case GREATERTHAN: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.GREATERTHAN); + break; + case LESSTHAN: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.LESSTHAN); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.EMPTY); + break; + case NOTEMPTY: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTEMPTY); + break; + case CONTAINS: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.CONTAINS); + break; + case NOTCONTAINS: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NOTCONTAINS); + break; + case EVAL: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.EVAL); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionOperatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionOperatorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorTypeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL); + } else { + switch (src.getValue()) { + case EQUALS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EQUALS); + break; + case NOTEQUALS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEQUALS); + break; + case IN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTIN); + break; + case GREATERTHAN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.GREATERTHAN); + break; + case LESSTHAN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.LESSTHAN); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EMPTY); + break; + case NOTEMPTY: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTEMPTY); + break; + case CONTAINS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.CONTAINS); + break; + case NOTCONTAINS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NOTCONTAINS); + break; + case EVAL: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.EVAL); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionOperatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.NULL); + } else { + switch (src.getValue()) { + case DELETE: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.DELETE); + break; + case GET: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.GET); + break; + case OPTIONS: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.OPTIONS); + break; + case PATCH: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.PATCH); + break; + case POST: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.POST); + break; + case PUT: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.PUT); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.TestScriptRequestMethodCode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertTestScriptRequestMethodCode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCodeEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL); + } else { + switch (src.getValue()) { + case DELETE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.DELETE); + break; + case GET: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.GET); + break; + case OPTIONS: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.OPTIONS); + break; + case PATCH: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PATCH); + break; + case POST: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.POST); + break; + case PUT: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.PUT); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.TestScriptRequestMethodCode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TestScript.AssertionResponseTypesEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NULL); + } else { + switch (src.getValue()) { + case OKAY: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.OKAY); + break; + case CREATED: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.CREATED); + break; + case NOCONTENT: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NOCONTENT); + break; + case NOTMODIFIED: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NOTMODIFIED); + break; + case BAD: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.BAD); + break; + case FORBIDDEN: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.FORBIDDEN); + break; + case NOTFOUND: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NOTFOUND); + break; + case METHODNOTALLOWED: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); + break; + case CONFLICT: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.CONFLICT); + break; + case GONE: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.GONE); + break; + case PRECONDITIONFAILED: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); + break; + case UNPROCESSABLE: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TestScript.AssertionResponseTypes.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.dstu3.model.Enumeration convertAssertionResponseTypes(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.dstu3.model.Enumeration tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypesEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL); + } else { + switch (src.getValue()) { + case OKAY: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.OKAY); + break; + case CREATED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CREATED); + break; + case NOCONTENT: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOCONTENT); + break; + case NOTMODIFIED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTMODIFIED); + break; + case BAD: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.BAD); + break; + case FORBIDDEN: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.FORBIDDEN); + break; + case NOTFOUND: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NOTFOUND); + break; + case METHODNOTALLOWED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.METHODNOTALLOWED); + break; + case CONFLICT: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.CONFLICT); + break; + case GONE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.GONE); + break; + case PRECONDITIONFAILED: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.PRECONDITIONFAILED); + break; + case UNPROCESSABLE: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.UNPROCESSABLE); + break; + default: + tgt.setValue(org.hl7.fhir.dstu3.model.TestScript.AssertionResponseTypes.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.dstu3.model.TestScript.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.r5.model.TestScript.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.TestActionComponent convertTestActionComponent(org.hl7.fhir.r5.model.TestScript.TestActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.TestActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TestActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + if (src.hasAssert()) tgt.setAssert(convertSetupActionAssertComponent(src.getAssert())); + return tgt; + } + + public static org.hl7.fhir.r5.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.r5.model.TestScript.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + public static org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent convertTeardownActionComponent(org.hl7.fhir.r5.model.TestScript.TeardownActionComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent tgt = new org.hl7.fhir.dstu3.model.TestScript.TeardownActionComponent(); + copyElement(src, tgt); + if (src.hasOperation()) tgt.setOperation(convertSetupActionOperationComponent(src.getOperation())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertFilterOperator(org.hl7.fhir.dstu3.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FilterOperatorEnumFactory()); + VersionConvertor_30_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NULL); + } else { + switch (src.getValue()) { + case EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.EQUAL); + break; + case ISA: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.ISA); + break; + case DESCENDENTOF: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.DESCENDENTOF); + break; + case ISNOTA: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.ISNOTA); + break; + case REGEX: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.REGEX); + break; + case IN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.IN); + break; + case NOTIN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NOTIN); + break; + case GENERALIZES: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.GENERALIZES); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.EXISTS); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FilterOperator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src, boolean nullOk) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.dstu3.model.Parameters) + return Parameters30_50.convertParameters((org.hl7.fhir.dstu3.model.Parameters) src); + if (src instanceof org.hl7.fhir.dstu3.model.ActivityDefinition) + return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.dstu3.model.ActivityDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.AllergyIntolerance) + return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.dstu3.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Appointment) + return Appointment30_50.convertAppointment((org.hl7.fhir.dstu3.model.Appointment) src); + if (src instanceof org.hl7.fhir.dstu3.model.AppointmentResponse) + return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.dstu3.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.AuditEvent) + return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.dstu3.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.dstu3.model.Basic) + return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); + if (src instanceof org.hl7.fhir.dstu3.model.Binary) + return Binary30_50.convertBinary((org.hl7.fhir.dstu3.model.Binary) src); + if (src instanceof org.hl7.fhir.dstu3.model.BodySite) + return BodySite30_50.convertBodySite((org.hl7.fhir.dstu3.model.BodySite) src); + if (src instanceof org.hl7.fhir.dstu3.model.Bundle) + return Bundle30_50.convertBundle((org.hl7.fhir.dstu3.model.Bundle) src); + if (src instanceof org.hl7.fhir.dstu3.model.CapabilityStatement) + return CapabilityStatement30_50.convertCapabilityStatement((org.hl7.fhir.dstu3.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.CarePlan) + return CarePlan30_50.convertCarePlan((org.hl7.fhir.dstu3.model.CarePlan) src); + if (src instanceof org.hl7.fhir.dstu3.model.CareTeam) + return CareTeam30_50.convertCareTeam((org.hl7.fhir.dstu3.model.CareTeam) src); + if (src instanceof org.hl7.fhir.dstu3.model.ClinicalImpression) + return ClinicalImpression30_50.convertClinicalImpression((org.hl7.fhir.dstu3.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.dstu3.model.CodeSystem) + return CodeSystem30_50.convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.Communication) + return Communication30_50.convertCommunication((org.hl7.fhir.dstu3.model.Communication) src); + if (src instanceof org.hl7.fhir.dstu3.model.CompartmentDefinition) + return CompartmentDefinition30_50.convertCompartmentDefinition((org.hl7.fhir.dstu3.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Composition) + return Composition30_50.convertComposition((org.hl7.fhir.dstu3.model.Composition) src); + if (src instanceof org.hl7.fhir.dstu3.model.ConceptMap) + return ConceptMap30_50.convertConceptMap((org.hl7.fhir.dstu3.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.dstu3.model.Condition) + return Condition30_50.convertCondition((org.hl7.fhir.dstu3.model.Condition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Consent) + return Consent30_50.convertConsent((org.hl7.fhir.dstu3.model.Consent) src); + if (src instanceof org.hl7.fhir.dstu3.model.DataElement) + return DataElement30_50.convertDataElement((org.hl7.fhir.dstu3.model.DataElement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DetectedIssue) + return DetectedIssue30_50.convertDetectedIssue((org.hl7.fhir.dstu3.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.dstu3.model.DeviceUseStatement) + return DeviceUseStatement30_50.convertDeviceUseStatement((org.hl7.fhir.dstu3.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.DiagnosticReport) + return DiagnosticReport30_50.convertDiagnosticReport((org.hl7.fhir.dstu3.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.dstu3.model.DocumentReference) + return DocumentReference30_50.convertDocumentReference((org.hl7.fhir.dstu3.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.dstu3.model.Encounter) + return Encounter30_50.convertEncounter((org.hl7.fhir.dstu3.model.Encounter) src); + if (src instanceof org.hl7.fhir.dstu3.model.Endpoint) + return Endpoint30_50.convertEndpoint((org.hl7.fhir.dstu3.model.Endpoint) src); + if (src instanceof org.hl7.fhir.dstu3.model.EpisodeOfCare) + return EpisodeOfCare30_50.convertEpisodeOfCare((org.hl7.fhir.dstu3.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.dstu3.model.ExpansionProfile) + return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.dstu3.model.ExpansionProfile) src); + if (src instanceof org.hl7.fhir.dstu3.model.FamilyMemberHistory) + return FamilyMemberHistory30_50.convertFamilyMemberHistory((org.hl7.fhir.dstu3.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.dstu3.model.Flag) return Flag30_50.convertFlag((org.hl7.fhir.dstu3.model.Flag) src); + if (src instanceof org.hl7.fhir.dstu3.model.Goal) return Goal30_50.convertGoal((org.hl7.fhir.dstu3.model.Goal) src); + if (src instanceof org.hl7.fhir.dstu3.model.GraphDefinition) + return GraphDefinition30_50.convertGraphDefinition((org.hl7.fhir.dstu3.model.GraphDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Group) + return Group30_50.convertGroup((org.hl7.fhir.dstu3.model.Group) src); + if (src instanceof org.hl7.fhir.dstu3.model.HealthcareService) + return HealthcareService30_50.convertHealthcareService((org.hl7.fhir.dstu3.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImagingStudy) + return ImagingStudy30_50.convertImagingStudy((org.hl7.fhir.dstu3.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.dstu3.model.Immunization) + return Immunization30_50.convertImmunization((org.hl7.fhir.dstu3.model.Immunization) src); + if (src instanceof org.hl7.fhir.dstu3.model.ImplementationGuide) + return ImplementationGuide30_50.convertImplementationGuide((org.hl7.fhir.dstu3.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.dstu3.model.Library) + return Library30_50.convertLibrary((org.hl7.fhir.dstu3.model.Library) src); + if (src instanceof org.hl7.fhir.dstu3.model.Linkage) + return Linkage30_50.convertLinkage((org.hl7.fhir.dstu3.model.Linkage) src); + if (src instanceof org.hl7.fhir.dstu3.model.ListResource) + return List30_50.convertList((org.hl7.fhir.dstu3.model.ListResource) src); + if (src instanceof org.hl7.fhir.dstu3.model.Location) + return Location30_50.convertLocation((org.hl7.fhir.dstu3.model.Location) src); + if (src instanceof org.hl7.fhir.dstu3.model.Measure) + return Measure30_50.convertMeasure((org.hl7.fhir.dstu3.model.Measure) src); + if (src instanceof org.hl7.fhir.dstu3.model.Media) + return Media30_50.convertMedia((org.hl7.fhir.dstu3.model.Media) src); + if (src instanceof org.hl7.fhir.dstu3.model.Medication) + return Medication30_50.convertMedication((org.hl7.fhir.dstu3.model.Medication) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationAdministration) + return MedicationAdministration30_50.convertMedicationAdministration((org.hl7.fhir.dstu3.model.MedicationAdministration) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationDispense) + return MedicationDispense30_50.convertMedicationDispense((org.hl7.fhir.dstu3.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationRequest) + return MedicationRequest30_50.convertMedicationRequest((org.hl7.fhir.dstu3.model.MedicationRequest) src); + if (src instanceof org.hl7.fhir.dstu3.model.MedicationStatement) + return MedicationStatement30_50.convertMedicationStatement((org.hl7.fhir.dstu3.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.dstu3.model.MessageDefinition) + return MessageDefinition30_50.convertMessageDefinition((org.hl7.fhir.dstu3.model.MessageDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.MessageHeader) + return MessageHeader30_50.convertMessageHeader((org.hl7.fhir.dstu3.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.dstu3.model.NamingSystem) + return NamingSystem30_50.convertNamingSystem((org.hl7.fhir.dstu3.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.dstu3.model.Observation) + return Observation30_50.convertObservation((org.hl7.fhir.dstu3.model.Observation) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationDefinition) + return OperationDefinition30_50.convertOperationDefinition((org.hl7.fhir.dstu3.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.OperationOutcome) + return OperationOutcome30_50.convertOperationOutcome((org.hl7.fhir.dstu3.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.dstu3.model.Organization) + return Organization30_50.convertOrganization((org.hl7.fhir.dstu3.model.Organization) src); + if (src instanceof org.hl7.fhir.dstu3.model.Patient) + return Patient30_50.convertPatient((org.hl7.fhir.dstu3.model.Patient) src); + if (src instanceof org.hl7.fhir.dstu3.model.PaymentNotice) + return PaymentNotice30_50.convertPaymentNotice((org.hl7.fhir.dstu3.model.PaymentNotice) src); + if (src instanceof org.hl7.fhir.dstu3.model.Person) + return Person30_50.convertPerson((org.hl7.fhir.dstu3.model.Person) src); + if (src instanceof org.hl7.fhir.dstu3.model.PlanDefinition) + return PlanDefinition30_50.convertPlanDefinition((org.hl7.fhir.dstu3.model.PlanDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.Practitioner) + return Practitioner30_50.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); + if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole) + return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src); + if (src instanceof org.hl7.fhir.dstu3.model.Provenance) + return Provenance30_50.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src); + if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) + return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) + return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.dstu3.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.dstu3.model.RelatedPerson) + return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.dstu3.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.dstu3.model.RiskAssessment) + return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.dstu3.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.dstu3.model.Schedule) + return Schedule30_50.convertSchedule((org.hl7.fhir.dstu3.model.Schedule) src); + if (src instanceof org.hl7.fhir.dstu3.model.SearchParameter) + return SearchParameter30_50.convertSearchParameter((org.hl7.fhir.dstu3.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.dstu3.model.Sequence) + return Sequence30_50.convertSequence((org.hl7.fhir.dstu3.model.Sequence) src); + if (src instanceof org.hl7.fhir.dstu3.model.Slot) return Slot30_50.convertSlot((org.hl7.fhir.dstu3.model.Slot) src); + if (src instanceof org.hl7.fhir.dstu3.model.Specimen) + return Specimen30_50.convertSpecimen((org.hl7.fhir.dstu3.model.Specimen) src); + if (src instanceof org.hl7.fhir.dstu3.model.StructureDefinition) + return StructureDefinition30_50.convertStructureDefinition((org.hl7.fhir.dstu3.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.dstu3.model.StructureMap) + return StructureMap30_50.convertStructureMap((org.hl7.fhir.dstu3.model.StructureMap) src); + if (src instanceof org.hl7.fhir.dstu3.model.Substance) + return Substance30_50.convertSubstance((org.hl7.fhir.dstu3.model.Substance) src); + if (src instanceof org.hl7.fhir.dstu3.model.SupplyDelivery) + return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.dstu3.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.dstu3.model.TestReport) + return TestReport30_50.convertTestReport((org.hl7.fhir.dstu3.model.TestReport) src); + if (src instanceof org.hl7.fhir.dstu3.model.TestScript) + return TestScript30_50.convertTestScript((org.hl7.fhir.dstu3.model.TestScript) src); + if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) + return ValueSet30_50.convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); + if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType()); + else return null; + } + + public static org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src, boolean nullOk) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r5.model.Parameters) { + if (((org.hl7.fhir.r5.model.Parameters) src).hasParameter("profile-url")) + return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.r5.model.Parameters) src); + else return Parameters30_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); + } + if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition) + return ActivityDefinition30_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance) + return AllergyIntolerance30_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.r5.model.Appointment) + return Appointment30_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); + if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) + return AppointmentResponse30_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.r5.model.AuditEvent) + return AuditEvent30_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.r5.model.Basic) return Basic30_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); + if (src instanceof org.hl7.fhir.r5.model.Binary) + return Binary30_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); + if (src instanceof org.hl7.fhir.r5.model.BodyStructure) + return BodySite30_50.convertBodySite((org.hl7.fhir.r5.model.BodyStructure) src); + if (src instanceof org.hl7.fhir.r5.model.Bundle) + return Bundle30_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src); + if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) + return CapabilityStatement30_50.convertCapabilityStatement((org.hl7.fhir.r5.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r5.model.CarePlan) + return CarePlan30_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); + if (src instanceof org.hl7.fhir.r5.model.CareTeam) + return CareTeam30_50.convertCareTeam((org.hl7.fhir.r5.model.CareTeam) src); + if (src instanceof org.hl7.fhir.r5.model.ClinicalImpression) + return ClinicalImpression30_50.convertClinicalImpression((org.hl7.fhir.r5.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.r5.model.CodeSystem) + return CodeSystem30_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.r5.model.Communication) + return Communication30_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); + if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition) + return CompartmentDefinition30_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Composition) + return Composition30_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); + if (src instanceof org.hl7.fhir.r5.model.ConceptMap) + return ConceptMap30_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r5.model.Condition) + return Condition30_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); + if (src instanceof org.hl7.fhir.r5.model.Consent) + return Consent30_50.convertConsent((org.hl7.fhir.r5.model.Consent) src); + if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) + return DetectedIssue30_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceUseStatement) + return DeviceUseStatement30_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) + return DiagnosticReport30_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.r5.model.DocumentReference) + return DocumentReference30_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r5.model.Encounter) + return Encounter30_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); + if (src instanceof org.hl7.fhir.r5.model.Endpoint) + return Endpoint30_50.convertEndpoint((org.hl7.fhir.r5.model.Endpoint) src); + if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) + return EpisodeOfCare30_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) + return FamilyMemberHistory30_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.r5.model.Flag) return Flag30_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); + if (src instanceof org.hl7.fhir.r5.model.Goal) return Goal30_50.convertGoal((org.hl7.fhir.r5.model.Goal) src); + if (src instanceof org.hl7.fhir.r5.model.GraphDefinition) + return GraphDefinition30_50.convertGraphDefinition((org.hl7.fhir.r5.model.GraphDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Group) return Group30_50.convertGroup((org.hl7.fhir.r5.model.Group) src); + if (src instanceof org.hl7.fhir.r5.model.HealthcareService) + return HealthcareService30_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.r5.model.ImagingStudy) + return ImagingStudy30_50.convertImagingStudy((org.hl7.fhir.r5.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.r5.model.Immunization) + return Immunization30_50.convertImmunization((org.hl7.fhir.r5.model.Immunization) src); + if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) + return ImplementationGuide30_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r5.model.Library) + return Library30_50.convertLibrary((org.hl7.fhir.r5.model.Library) src); + if (src instanceof org.hl7.fhir.r5.model.Linkage) + return Linkage30_50.convertLinkage((org.hl7.fhir.r5.model.Linkage) src); + if (src instanceof org.hl7.fhir.r5.model.ListResource) + return List30_50.convertList((org.hl7.fhir.r5.model.ListResource) src); + if (src instanceof org.hl7.fhir.r5.model.Location) + return Location30_50.convertLocation((org.hl7.fhir.r5.model.Location) src); + if (src instanceof org.hl7.fhir.r5.model.Measure) + return Measure30_50.convertMeasure((org.hl7.fhir.r5.model.Measure) src); + if (src instanceof org.hl7.fhir.r5.model.DocumentReference) + return Media30_50.convertMedia((org.hl7.fhir.r5.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r5.model.Medication) + return Medication30_50.convertMedication((org.hl7.fhir.r5.model.Medication) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationAdministration) + return MedicationAdministration30_50.convertMedicationAdministration((org.hl7.fhir.r5.model.MedicationAdministration) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) + return MedicationDispense30_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationRequest) + return MedicationRequest30_50.convertMedicationRequest((org.hl7.fhir.r5.model.MedicationRequest) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationUsage) + return MedicationStatement30_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationUsage) src); + if (src instanceof org.hl7.fhir.r5.model.MessageDefinition) + return MessageDefinition30_50.convertMessageDefinition((org.hl7.fhir.r5.model.MessageDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.MessageHeader) + return MessageHeader30_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.r5.model.NamingSystem) + return NamingSystem30_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r5.model.Observation) + return Observation30_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); + if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) + return OperationDefinition30_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) + return OperationOutcome30_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r5.model.Organization) + return Organization30_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); + if (src instanceof org.hl7.fhir.r5.model.Patient) + return Patient30_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); + if (src instanceof org.hl7.fhir.r5.model.PaymentNotice) + return PaymentNotice30_50.convertPaymentNotice((org.hl7.fhir.r5.model.PaymentNotice) src); + if (src instanceof org.hl7.fhir.r5.model.Person) + return Person30_50.convertPerson((org.hl7.fhir.r5.model.Person) src); + if (src instanceof org.hl7.fhir.r5.model.PlanDefinition) + return PlanDefinition30_50.convertPlanDefinition((org.hl7.fhir.r5.model.PlanDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Practitioner) + return Practitioner30_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); + if (src instanceof org.hl7.fhir.r5.model.PractitionerRole) + return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src); + if (src instanceof org.hl7.fhir.r5.model.Provenance) + return Provenance30_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); + if (src instanceof org.hl7.fhir.r5.model.Questionnaire) + return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) + return QuestionnaireResponse30_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r5.model.RelatedPerson) + return RelatedPerson30_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) + return RiskAssessment30_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.r5.model.Schedule) + return Schedule30_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); + if (src instanceof org.hl7.fhir.r5.model.SearchParameter) + return SearchParameter30_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r5.model.MolecularSequence) + return Sequence30_50.convertSequence((org.hl7.fhir.r5.model.MolecularSequence) src); + if (src instanceof org.hl7.fhir.r5.model.Slot) return Slot30_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); + if (src instanceof org.hl7.fhir.r5.model.Specimen) + return Specimen30_50.convertSpecimen((org.hl7.fhir.r5.model.Specimen) src); + if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) + return StructureDefinition30_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.StructureMap) + return StructureMap30_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src); + if (src instanceof org.hl7.fhir.r5.model.Substance) + return Substance30_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); + if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) + return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r5.model.TestReport) + return TestReport30_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); + if (src instanceof org.hl7.fhir.r5.model.TestScript) + return TestScript30_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); + if (src instanceof org.hl7.fhir.r5.model.ValueSet) + return ValueSet30_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); + if (!nullOk) throw new FHIRException("Unknown resource " + src.fhirType()); + else return null; + } + + public static TerminologyCapabilities convertTerminologyCapabilities(Parameters src, boolean b) { + TerminologyCapabilities res = new TerminologyCapabilities(); + for (ParametersParameterComponent p : src.getParameter()) { + if (p.getName().equals("system")) res.addCodeSystem().setUri(p.getValue().primitiveValue()); + if (p.getName().equals("expansion.parameter")) + res.getExpansion().addParameter().setName(p.getValue().primitiveValue()); + } + return res; + } + + public static boolean convertsResource(String rt) { + return Utilities.existsInList(rt, "Parameters", "ActivityDefinition", "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodyStructure", "Bundle", "CapabilityStatement", "CarePlan", "CareTeam", "ClinicalImpression", "CodeSystem", "Communication", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Consent", "DetectedIssue", "DeviceUseStatement", "DiagnosticReport", "DocumentReference", "Encounter", "Endpoint", "EpisodeOfCare", "FamilyMemberHistory", "Flag", "Goal", "GraphDefinition", "Group", "HealthcareService", "ImagingStudy", "Immunization", "ImplementationGuide", "Library", "Linkage", "ListResource", "Location", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationRequest", "MedicationStatement", "MessageDefinition", "MessageHeader", "NamingSystem", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Patient", "PaymentNotice", "Person", "PlanDefinition", "Practitioner", "PractitionerRole", "ProcessRequest", "Questionnaire", "QuestionnaireResponse", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "Slot", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "TestReport", "TestScript", "ValueSet"); + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java index 973d8515a..700a8eed4 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java @@ -1,12 +1,5 @@ package org.hl7.fhir.convertors; - -/* - * public static final String EXT_JSON_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type"; - public static final String EXT_RDF_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-rdf-type"; - public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type"; - - */ import org.hl7.fhir.convertors.conv40_50.*; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.model.CodeableReference; @@ -17,4450 +10,3915 @@ import java.util.stream.Collectors; Copyright (c) 2011+, HL7, Inc. All rights reserved. - Redistribution and use in source and binary forms, with or without modification, + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 + public class VersionConvertor_40_50 { - - static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { - boolean ok = false; - for (String s : extensionsToIgnore) if (s.equals(url)) - ok = true; - return ok; - } - - protected static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - protected static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... extensionsToIgnore) throws FHIRException { - if (src.hasId()) tgt.setId(src.getId()); - for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { - if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { - tgt.addExtension(convertExtension(e)); - } - } - } - - protected static void copyEnumeration(org.hl7.fhir.r4.model.Enumeration src, org.hl7.fhir.r5.model.Enumeration tgt) throws FHIRException { - if (src.hasId()) tgt.setId(src.getId()); - for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - protected static void copyEnumeration(org.hl7.fhir.r5.model.Enumeration src, org.hl7.fhir.r4.model.Enumeration tgt) throws FHIRException { - if (src.hasId()) tgt.setId(src.getId()); - for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { - tgt.addExtension(convertExtension(e)); - } - } - - protected static void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.r5.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - protected static void copyBackboneElement(org.hl7.fhir.r5.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - protected static void copyBackboneElement(org.hl7.fhir.r5.model.BackboneType src, org.hl7.fhir.r4.model.BackboneType tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - protected static void copyBackboneElement(org.hl7.fhir.r4.model.BackboneType src, org.hl7.fhir.r5.model.BackboneType tgt) throws FHIRException { - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { - tgt.addModifierExtension(convertExtension(e)); - } - } - - protected static org.hl7.fhir.utilities.xhtml.XhtmlNode convertXhtml(org.hl7.fhir.utilities.xhtml.XhtmlNode src) throws FHIRException { - return src; - } - - public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { - org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { - org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.CanonicalType convertCanonical(org.hl7.fhir.r4.model.CanonicalType src) throws FHIRException { - org.hl7.fhir.r5.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CanonicalType(src.getValue()) : new org.hl7.fhir.r5.model.CanonicalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.CanonicalType convertCanonical(org.hl7.fhir.r5.model.CanonicalType src) throws FHIRException { - org.hl7.fhir.r4.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CanonicalType(src.getValue()) : new org.hl7.fhir.r4.model.CanonicalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { - org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { - org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { - org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValue()) : new org.hl7.fhir.r5.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { - org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValue()) : new org.hl7.fhir.r4.model.DateType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { - org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { - org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { - org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { - org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { - org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { - org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValueAsString()) : new org.hl7.fhir.r5.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Integer64Type convertUnsignedIntToInteger64(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.Integer64Type tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Integer64Type(src.getValueAsString()) : new org.hl7.fhir.r5.model.Integer64Type(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UnsignedIntType convertInteger64ToUnsignedInt(org.hl7.fhir.r5.model.Integer64Type src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValueAsString()) : new org.hl7.fhir.r4.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { - org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValueAsString()) : new org.hl7.fhir.r4.model.IntegerType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { - org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { - org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { - org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { - org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.r4.model.StringType src) throws FHIRException { - org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); - copyElement(src, tgt); - return tgt; + static public boolean isExemptExtension(String url, String[] extensionsToIgnore) { + boolean ok = false; + for (String s : extensionsToIgnore) if (s.equals(url)) ok = true; + return ok; } - public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { - org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { - org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { - org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { - org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { - org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { - org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UrlType convertUrl(org.hl7.fhir.r4.model.UrlType src) throws FHIRException { - org.hl7.fhir.r5.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UrlType(src.getValue()) : new org.hl7.fhir.r5.model.UrlType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UrlType convertUrl(org.hl7.fhir.r5.model.UrlType src) throws FHIRException { - org.hl7.fhir.r4.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UrlType(src.getValue()) : new org.hl7.fhir.r4.model.UrlType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { - org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { - org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); - copyElement(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); - copyElement(src, tgt); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); - copyElement(src, tgt); - if (src.hasUrl()) - tgt.setUrlElement(convertUri(src.getUrlElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(convertXhtml(src.getDiv())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); - copyElement(src, tgt); - if (src.hasStatus()) - tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); - if (src.hasDiv()) - tgt.setDiv(convertXhtml(src.getDiv())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case GENERATED: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); - break; - case EXTENSIONS: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); - break; - case ADDITIONAL: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); - break; - case EMPTY: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.getLine().add(convertString(t)); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertAddressUse(src.getUseElement())); - if (src.hasType()) - tgt.setTypeElement(convertAddressType(src.getTypeElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.getLine().add(convertString(t)); - if (src.hasCity()) - tgt.setCityElement(convertString(src.getCityElement())); - if (src.hasDistrict()) - tgt.setDistrictElement(convertString(src.getDistrictElement())); - if (src.hasState()) - tgt.setStateElement(convertString(src.getStateElement())); - if (src.hasPostalCode()) - tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); - if (src.hasCountry()) - tgt.setCountryElement(convertString(src.getCountryElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); - break; - case BILLING: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.BILLING); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); - break; - case BILLING: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.BILLING); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case POSTAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); - break; - case PHYSICAL: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); - break; - case BOTH: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setTextElement(convertMarkdown(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); - copyElement(src, tgt); - if (src.hasAuthor()) - tgt.setAuthor(convertType(src.getAuthor())); - if (src.hasTime()) - tgt.setTimeElement(convertDateTime(src.getTimeElement())); - if (src.hasText()) - tgt.setTextElement(convertMarkdown(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrlElement(convertUrl(src.getUrlElement())); - if (src.hasSize()) - tgt.setSizeElement(convertUnsignedIntToInteger64(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); - copyElement(src, tgt); - if (src.hasContentType()) - tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - if (src.hasUrl()) - tgt.setUrlElement(convertUrl(src.getUrlElement())); - if (src.hasSize()) - tgt.setSizeElement(convertInteger64ToUnsignedInt(src.getSizeElement())); - if (src.hasHash()) - tgt.setHashElement(convertBase64Binary(src.getHashElement())); - if (src.hasTitle()) - tgt.setTitleElement(convertString(src.getTitleElement())); - if (src.hasCreation()) - tgt.setCreationElement(convertDateTime(src.getCreationElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasVersion()) - tgt.setVersionElement(convertString(src.getVersionElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasUserSelected()) - tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ContactDetail convertContactDetail(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.ContactDetail convertContactDetail(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); - copyElement(src, tgt); - if (src.hasSystem()) - tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasUse()) - tgt.setUseElement(convertContactPointUse(src.getUseElement())); - if (src.hasRank()) - tgt.setRankElement(convertPositiveInt(src.getRankElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.URL); - break; - case SMS: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.SMS); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case PHONE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); - break; - case FAX: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); - break; - case EMAIL: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); - break; - case PAGER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); - break; - case URL: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL); - break; - case SMS: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS); - break; - case OTHER: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case HOME: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); - break; - case WORK: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); - break; - case MOBILE: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Contributor convertContributor(org.hl7.fhir.r4.model.Contributor src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Contributor tgt = new org.hl7.fhir.r5.model.Contributor(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertContributorType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.Contributor convertContributor(org.hl7.fhir.r5.model.Contributor src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Contributor tgt = new org.hl7.fhir.r4.model.Contributor(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertContributorType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertContributorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Contributor.ContributorTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case AUTHOR: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.AUTHOR); - break; - case EDITOR: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.EDITOR); - break; - case REVIEWER: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.REVIEWER); - break; - case ENDORSER: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.ENDORSER); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertContributorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Contributor.ContributorTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case AUTHOR: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.AUTHOR); - break; - case EDITOR: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.EDITOR); - break; - case REVIEWER: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.REVIEWER); - break; - case ENDORSER: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.ENDORSER); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement convertDataRequirement(org.hl7.fhir.r4.model.DataRequirement src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement tgt = new org.hl7.fhir.r5.model.DataRequirement(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); - for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); - if (src.hasSubject()) - tgt.setSubject(convertType(src.getSubject())); - for (org.hl7.fhir.r4.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t)); - for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); - for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); - if (src.hasLimit()) - tgt.setLimitElement(convertPositiveInt(src.getLimitElement())); - for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent t : src.getSort()) tgt.addSort(convertDataRequirementSortComponent(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement convertDataRequirement(org.hl7.fhir.r5.model.DataRequirement src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement tgt = new org.hl7.fhir.r4.model.DataRequirement(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(src.getType().toCode()); - for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); - if (src.hasSubject()) - tgt.setSubject(convertType(src.getSubject())); - for (org.hl7.fhir.r5.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t)); - for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); - for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); - if (src.hasLimit()) - tgt.setLimitElement(convertPositiveInt(src.getLimitElement())); - for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent t : src.getSort()) tgt.addSort(convertDataRequirementSortComponent(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasSearchParam()) - tgt.setSearchParamElement(convertString(src.getSearchParamElement())); - if (src.hasValueSet()) - tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasSearchParam()) - tgt.setSearchParamElement(convertString(src.getSearchParamElement())); - if (src.hasValueSet()) - tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); - for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasSearchParam()) - tgt.setSearchParamElement(convertString(src.getSearchParamElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasSearchParam()) - tgt.setSearchParamElement(convertString(src.getSearchParamElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent convertDataRequirementSortComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasDirection()) - tgt.setDirectionElement(convertSortDirection(src.getDirectionElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent convertDataRequirementSortComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasDirection()) - tgt.setDirectionElement(convertSortDirection(src.getDirectionElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSortDirection(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.DataRequirement.SortDirectionEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case ASCENDING: - tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.ASCENDING); - break; - case DESCENDING: - tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.DESCENDING); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSortDirection(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.DataRequirement.SortDirectionEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case ASCENDING: - tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.ASCENDING); - break; - case DESCENDING: - tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.DESCENDING); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Dosage convertDosage(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Dosage tgt = new org.hl7.fhir.r5.model.Dosage(); - copyBackboneElement(src, tgt); - if (src.hasSequence()) - tgt.setSequenceElement(convertInteger(src.getSequenceElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAdditionalInstruction()) tgt.addAdditionalInstruction(convertCodeableConcept(t)); - if (src.hasPatientInstruction()) - tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertCodeableConcept(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - for (org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent t : src.getDoseAndRate()) tgt.addDoseAndRate(convertDosageDoseAndRateComponent(t)); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - if (src.hasMaxDosePerAdministration()) - tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); - if (src.hasMaxDosePerLifetime()) - tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Dosage convertDosage(org.hl7.fhir.r5.model.Dosage src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); - copyBackboneElement(src, tgt); - if (src.hasSequence()) - tgt.setSequenceElement(convertInteger(src.getSequenceElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - for (org.hl7.fhir.r5.model.CodeableConcept t : src.getAdditionalInstruction()) tgt.addAdditionalInstruction(convertCodeableConcept(t)); - if (src.hasPatientInstruction()) - tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); - if (src.hasTiming()) - tgt.setTiming(convertTiming(src.getTiming())); - if (src.hasAsNeeded()) - tgt.setAsNeeded(convertType(src.getAsNeeded())); - if (src.hasSite()) - tgt.setSite(convertCodeableConcept(src.getSite())); - if (src.hasRoute()) - tgt.setRoute(convertCodeableConcept(src.getRoute())); - if (src.hasMethod()) - tgt.setMethod(convertCodeableConcept(src.getMethod())); - for (org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent t : src.getDoseAndRate()) tgt.addDoseAndRate(convertDosageDoseAndRateComponent(t)); - if (src.hasMaxDosePerPeriod()) - tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); - if (src.hasMaxDosePerAdministration()) - tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); - if (src.hasMaxDosePerLifetime()) - tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent convertDosageDoseAndRateComponent(org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent tgt = new org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasDose()) - tgt.setDose(convertType(src.getDose())); - if (src.hasRate()) - tgt.setRate(convertType(src.getRate())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent convertDosageDoseAndRateComponent(org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent tgt = new org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasDose()) - tgt.setDose(convertType(src.getDose())); - if (src.hasRate()) - tgt.setRate(convertType(src.getRate())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); - copyQuantity(src, tgt); - return tgt; - } - - public static org.hl7.fhir.r5.model.Expression convertExpression(org.hl7.fhir.r4.model.Expression src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Expression tgt = new org.hl7.fhir.r5.model.Expression(); - copyElement(src, tgt); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasName()) - tgt.setNameElement(convertId(src.getNameElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasReference()) - tgt.setReferenceElement(convertUri(src.getReferenceElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Expression convertExpression(org.hl7.fhir.r5.model.Expression src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Expression tgt = new org.hl7.fhir.r4.model.Expression(); - copyElement(src, tgt); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasName()) - tgt.setNameElement(convertId(src.getNameElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasReference()) - tgt.setReferenceElement(convertUri(src.getReferenceElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.setFamilyElement(convertString(src.getFamilyElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.getGiven().add(convertString(t)); - for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.getPrefix().add(convertString(t)); - for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.getSuffix().add(convertString(t)); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertNameUse(src.getUseElement())); - if (src.hasText()) - tgt.setTextElement(convertString(src.getTextElement())); - if (src.hasFamily()) - tgt.setFamilyElement(convertString(src.getFamilyElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.getGiven().add(convertString(t)); - for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.getPrefix().add(convertString(t)); - for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.getSuffix().add(convertString(t)); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); - break; - case NICKNAME: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); - break; - case ANONYMOUS: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); - break; - case MAIDEN: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); - copyElement(src, tgt); - if (src.hasUse()) - tgt.setUseElement(convertIdentifierUse(src.getUseElement())); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasValue()) - tgt.setValueElement(convertString(src.getValueElement())); - if (src.hasPeriod()) - tgt.setPeriod(convertPeriod(src.getPeriod())); - if (src.hasAssigner()) - tgt.setAssigner(convertReference(src.getAssigner())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case USUAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); - break; - case OFFICIAL: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); - break; - case TEMP: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); - break; - case SECONDARY: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); - break; - case OLD: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OLD); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.MarketingStatus convertMarketingStatus(org.hl7.fhir.r4.model.MarketingStatus src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.MarketingStatus tgt = new org.hl7.fhir.r5.model.MarketingStatus(); - copyBackboneElement(src, tgt); - if (src.hasCountry()) - tgt.setCountry(convertCodeableConcept(src.getCountry())); - if (src.hasJurisdiction()) - tgt.setJurisdiction(convertCodeableConcept(src.getJurisdiction())); - if (src.hasStatus()) - tgt.setStatus(convertCodeableConcept(src.getStatus())); - if (src.hasDateRange()) - tgt.setDateRange(convertPeriod(src.getDateRange())); - if (src.hasRestoreDate()) - tgt.setRestoreDateElement(convertDateTime(src.getRestoreDateElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.MarketingStatus convertMarketingStatus(org.hl7.fhir.r5.model.MarketingStatus src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.MarketingStatus tgt = new org.hl7.fhir.r4.model.MarketingStatus(); - copyBackboneElement(src, tgt); - if (src.hasCountry()) - tgt.setCountry(convertCodeableConcept(src.getCountry())); - if (src.hasJurisdiction()) - tgt.setJurisdiction(convertCodeableConcept(src.getJurisdiction())); - if (src.hasStatus()) - tgt.setStatus(convertCodeableConcept(src.getStatus())); - if (src.hasDateRange()) - tgt.setDateRange(convertPeriod(src.getDateRange())); - if (src.hasRestoreDate()) - tgt.setRestoreDateElement(convertDateTime(src.getRestoreDateElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - if (src.hasSource()) - tgt.setSourceElement(convertUri(src.getSourceElement())); - for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); - for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); - copyElement(src, tgt); - if (src.hasVersionId()) - tgt.setVersionIdElement(convertId(src.getVersionIdElement())); - if (src.hasLastUpdated()) - tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); - if (src.hasSource()) - tgt.setSourceElement(convertUri(src.getSourceElement())); - for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); - for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); - for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); - return tgt; - } - - public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrency()) - tgt.setCurrencyElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasCurrency()) - tgt.setCurrencyElement(convertCode(src.getCurrencyElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ParameterDefinition tgt = new org.hl7.fhir.r5.model.ParameterDefinition(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertCode(src.getNameElement())); - if (src.hasUse()) - tgt.setUseElement(convertParameterUse(src.getUseElement())); - if (src.hasMin()) - tgt.setMinElement(convertInteger(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasDocumentation()) - tgt.setDocumentationElement(convertString(src.getDocumentationElement())); - if (src.hasType()) - tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); - if (src.hasProfile()) - tgt.setProfileElement(convertCanonical(src.getProfileElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ParameterDefinition tgt = new org.hl7.fhir.r4.model.ParameterDefinition(); - copyElement(src, tgt); - if (src.hasName()) - tgt.setNameElement(convertCode(src.getNameElement())); - if (src.hasUse()) - tgt.setUseElement(convertParameterUse(src.getUseElement())); - if (src.hasMin()) - tgt.setMinElement(convertInteger(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasDocumentation()) - tgt.setDocumentationElement(convertString(src.getDocumentationElement())); - if (src.hasType()) - tgt.setType(src.getType().toCode()); - if (src.hasProfile()) - tgt.setProfileElement(convertCanonical(src.getProfileElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertParameterUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.OperationParameterUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case IN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.IN); - break; - case OUT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.OUT); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertParameterUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ParameterDefinition.ParameterUseEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case IN: - tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.IN); - break; - case OUT: - tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.OUT); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); - copyElement(src, tgt); - if (src.hasStart()) - tgt.setStartElement(convertDateTime(src.getStartElement())); - if (src.hasEnd()) - tgt.setEndElement(convertDateTime(src.getEndElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Population convertPopulation(org.hl7.fhir.r4.model.Population src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Population tgt = new org.hl7.fhir.r5.model.Population(); - copyBackboneElement(src, tgt); - if (src.hasAge()) - tgt.setAge(convertType(src.getAge())); - if (src.hasGender()) - tgt.setGender(convertCodeableConcept(src.getGender())); - if (src.hasRace()) - tgt.setRace(convertCodeableConcept(src.getRace())); - if (src.hasPhysiologicalCondition()) - tgt.setPhysiologicalCondition(convertCodeableConcept(src.getPhysiologicalCondition())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Population convertPopulation(org.hl7.fhir.r5.model.Population src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Population tgt = new org.hl7.fhir.r4.model.Population(); - copyBackboneElement(src, tgt); - if (src.hasAge()) - tgt.setAge(convertType(src.getAge())); - if (src.hasGender()) - tgt.setGender(convertCodeableConcept(src.getGender())); - if (src.hasRace()) - tgt.setRace(convertCodeableConcept(src.getRace())); - if (src.hasPhysiologicalCondition()) - tgt.setPhysiologicalCondition(convertCodeableConcept(src.getPhysiologicalCondition())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ProdCharacteristic convertProdCharacteristic(org.hl7.fhir.r4.model.ProdCharacteristic src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ProdCharacteristic tgt = new org.hl7.fhir.r5.model.ProdCharacteristic(); - copyBackboneElement(src, tgt); - if (src.hasHeight()) - tgt.setHeight(convertQuantity(src.getHeight())); - if (src.hasWidth()) - tgt.setWidth(convertQuantity(src.getWidth())); - if (src.hasDepth()) - tgt.setDepth(convertQuantity(src.getDepth())); - if (src.hasWeight()) - tgt.setWeight(convertQuantity(src.getWeight())); - if (src.hasNominalVolume()) - tgt.setNominalVolume(convertQuantity(src.getNominalVolume())); - if (src.hasExternalDiameter()) - tgt.setExternalDiameter(convertQuantity(src.getExternalDiameter())); - if (src.hasShape()) - tgt.setShapeElement(convertString(src.getShapeElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getColor()) tgt.getColor().add(convertString(t)); - for (org.hl7.fhir.r4.model.StringType t : src.getImprint()) tgt.getImprint().add(convertString(t)); - for (org.hl7.fhir.r4.model.Attachment t : src.getImage()) tgt.addImage(convertAttachment(t)); - if (src.hasScoring()) - tgt.setScoring(convertCodeableConcept(src.getScoring())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ProdCharacteristic convertProdCharacteristic(org.hl7.fhir.r5.model.ProdCharacteristic src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ProdCharacteristic tgt = new org.hl7.fhir.r4.model.ProdCharacteristic(); - copyBackboneElement(src, tgt); - if (src.hasHeight()) - tgt.setHeight(convertQuantity(src.getHeight())); - if (src.hasWidth()) - tgt.setWidth(convertQuantity(src.getWidth())); - if (src.hasDepth()) - tgt.setDepth(convertQuantity(src.getDepth())); - if (src.hasWeight()) - tgt.setWeight(convertQuantity(src.getWeight())); - if (src.hasNominalVolume()) - tgt.setNominalVolume(convertQuantity(src.getNominalVolume())); - if (src.hasExternalDiameter()) - tgt.setExternalDiameter(convertQuantity(src.getExternalDiameter())); - if (src.hasShape()) - tgt.setShapeElement(convertString(src.getShapeElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getColor()) tgt.getColor().add(convertString(t)); - for (org.hl7.fhir.r5.model.StringType t : src.getImprint()) tgt.getImprint().add(convertString(t)); - for (org.hl7.fhir.r5.model.Attachment t : src.getImage()) tgt.addImage(convertAttachment(t)); - if (src.hasScoring()) - tgt.setScoring(convertCodeableConcept(src.getScoring())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ProductShelfLife convertProductShelfLife(org.hl7.fhir.r4.model.ProductShelfLife src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ProductShelfLife tgt = new org.hl7.fhir.r5.model.ProductShelfLife(); - copyBackboneElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasPeriod()) - tgt.setPeriod(convertQuantity(src.getPeriod())); - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialPrecautionsForStorage()) tgt.addSpecialPrecautionsForStorage(convertCodeableConcept(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.ProductShelfLife convertProductShelfLife(org.hl7.fhir.r5.model.ProductShelfLife src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ProductShelfLife tgt = new org.hl7.fhir.r4.model.ProductShelfLife(); - copyBackboneElement(src, tgt); - if (src.hasType()) - tgt.setType(convertCodeableConcept(src.getType())); - if (src.hasPeriodQuantity()) - tgt.setPeriod(convertQuantity(src.getPeriodQuantity())); - for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialPrecautionsForStorage()) tgt.addSpecialPrecautionsForStorage(convertCodeableConcept(t)); - return tgt; - } - - public static void copyQuantity(org.hl7.fhir.r4.model.Quantity src, org.hl7.fhir.r5.model.Quantity tgt) throws FHIRException { - if (src == null || tgt == null) - return; - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnit(src.getUnit()); - if (src.hasSystem()) - tgt.setSystem(src.getSystem()); - if (src.hasCode()) - tgt.setCode(src.getCode()); - } - - public static void copyQuantity(org.hl7.fhir.r5.model.Quantity src, org.hl7.fhir.r4.model.Quantity tgt) throws FHIRException { - if (src == null || tgt == null) - return; - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValue(src.getValue()); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnit(src.getUnit()); - if (src.hasSystem()) - tgt.setSystem(src.getSystem()); - if (src.hasCode()) - tgt.setCode(src.getCode()); - } - - public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case LESS_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); - break; - case LESS_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); - break; - case GREATER_OR_EQUAL: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); - break; - case GREATER_THAN: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); - copyElement(src, tgt); - if (src.hasLow()) - tgt.setLow(convertSimpleQuantity(src.getLow())); - if (src.hasHigh()) - tgt.setHigh(convertSimpleQuantity(src.getHigh())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); - copyElement(src, tgt); - if (src.hasNumerator()) - tgt.setNumerator(convertQuantity(src.getNumerator())); - if (src.hasDenominator()) - tgt.setDenominator(convertQuantity(src.getDenominator())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReferenceElement(convertString(src.getReferenceElement_())); - if (src.hasType()) - tgt.setTypeElement(convertUri(src.getTypeElement())); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); - copyElement(src, tgt); - if (src.hasReference()) - tgt.setReferenceElement(convertString(src.getReferenceElement_())); - if (src.hasType()) - tgt.setTypeElement(convertUri(src.getTypeElement())); - if (src.hasIdentifier()) - tgt.setIdentifier(convertIdentifier(src.getIdentifier())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.RelatedArtifact tgt = new org.hl7.fhir.r5.model.RelatedArtifact(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasCitation()) - tgt.setCitationElement(convertMarkdown(src.getCitationElement())); - if (src.hasUrl()) - tgt.setUrlElement(convertUrl(src.getUrlElement())); - if (src.hasDocument()) - tgt.setDocument(convertAttachment(src.getDocument())); - if (src.hasResource()) - tgt.setResourceElement(convertCanonical(src.getResourceElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.RelatedArtifact tgt = new org.hl7.fhir.r4.model.RelatedArtifact(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasDisplay()) - tgt.setDisplayElement(convertString(src.getDisplayElement())); - if (src.hasCitation()) - tgt.setCitationElement(convertMarkdown(src.getCitationElement())); - if (src.hasUrl()) - tgt.setUrlElement(convertUrl(src.getUrlElement())); - if (src.hasDocument()) - tgt.setDocument(convertAttachment(src.getDocument())); - if (src.hasResource()) - tgt.setResourceElement(convertCanonical(src.getResourceElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case DOCUMENTATION: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); - break; - case JUSTIFICATION: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); - break; - case CITATION: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.CITATION); - break; - case PREDECESSOR: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); - break; - case SUCCESSOR: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); - break; - case DERIVEDFROM: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); - break; - case DEPENDSON: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - break; - case COMPOSEDOF: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case DOCUMENTATION: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); - break; - case JUSTIFICATION: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); - break; - case CITATION: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.CITATION); - break; - case PREDECESSOR: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); - break; - case SUCCESSOR: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); - break; - case DERIVEDFROM: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); - break; - case DEPENDSON: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - break; - case COMPOSEDOF: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensions()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasData()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); - copyElement(src, tgt); - if (src.hasOrigin()) - tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasFactor()) - tgt.setFactorElement(convertDecimal(src.getFactorElement())); - if (src.hasLowerLimit()) - tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); - if (src.hasUpperLimit()) - tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); - if (src.hasDimensions()) - tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); - if (src.hasData()) - tgt.setDataElement(convertString(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhen()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertReference(src.getWho())); - if (src.hasOnBehalfOf()) - tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf())); - if (src.hasTargetFormat()) - tgt.setTargetFormatElement(convertCode(src.getTargetFormatElement())); - if (src.hasSigFormat()) - tgt.setSigFormatElement(convertCode(src.getSigFormatElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); - if (src.hasWhen()) - tgt.setWhenElement(convertInstant(src.getWhenElement())); - if (src.hasWho()) - tgt.setWho(convertReference(src.getWho())); - if (src.hasOnBehalfOf()) - tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf())); - if (src.hasTargetFormat()) - tgt.setTargetFormatElement(convertCode(src.getTargetFormatElement())); - if (src.hasSigFormat()) - tgt.setSigFormatElement(convertCode(src.getSigFormatElement())); - if (src.hasData()) - tgt.setDataElement(convertBase64Binary(src.getDataElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.SubstanceAmount convertSubstanceAmount(org.hl7.fhir.r4.model.SubstanceAmount src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.SubstanceAmount tgt = new org.hl7.fhir.r5.model.SubstanceAmount(); - copyBackboneElement(src, tgt); - if (src.hasAmount()) - tgt.setAmount(convertType(src.getAmount())); - if (src.hasAmountType()) - tgt.setAmountType(convertCodeableConcept(src.getAmountType())); - if (src.hasAmountText()) - tgt.setAmountTextElement(convertString(src.getAmountTextElement())); - if (src.hasReferenceRange()) - tgt.setReferenceRange(convertSubstanceAmountReferenceRangeComponent(src.getReferenceRange())); - return tgt; - } - - public static org.hl7.fhir.r4.model.SubstanceAmount convertSubstanceAmount(org.hl7.fhir.r5.model.SubstanceAmount src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.SubstanceAmount tgt = new org.hl7.fhir.r4.model.SubstanceAmount(); - copyBackboneElement(src, tgt); - if (src.hasAmount()) - tgt.setAmount(convertType(src.getAmount())); - if (src.hasAmountType()) - tgt.setAmountType(convertCodeableConcept(src.getAmountType())); - if (src.hasAmountText()) - tgt.setAmountTextElement(convertString(src.getAmountTextElement())); - if (src.hasReferenceRange()) - tgt.setReferenceRange(convertSubstanceAmountReferenceRangeComponent(src.getReferenceRange())); - return tgt; - } - - public static org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent convertSubstanceAmountReferenceRangeComponent(org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent tgt = new org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent(); - copyElement(src, tgt); - if (src.hasLowLimit()) - tgt.setLowLimit(convertQuantity(src.getLowLimit())); - if (src.hasHighLimit()) - tgt.setHighLimit(convertQuantity(src.getHighLimit())); - return tgt; - } - - public static org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent convertSubstanceAmountReferenceRangeComponent(org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent tgt = new org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent(); - copyElement(src, tgt); - if (src.hasLowLimit()) - tgt.setLowLimit(convertQuantity(src.getLowLimit())); - if (src.hasHighLimit()) - tgt.setHighLimit(convertQuantity(src.getHighLimit())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); - copyBackboneElement(src, tgt); - for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.getEvent().add(convertDateTime(t)); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); - copyBackboneElement(src, tgt); - for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.getEvent().add(convertDateTime(t)); - if (src.hasRepeat()) - tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); - if (src.hasCode()) - tgt.setCode(convertCodeableConcept(src.getCode())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCountElement(convertPositiveInt(src.getCountElement())); - if (src.hasCountMax()) - tgt.setCountMaxElement(convertPositiveInt(src.getCountMaxElement())); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequencyElement(convertPositiveInt(src.getFrequencyElement())); - if (src.hasFrequencyMax()) - tgt.setFrequencyMaxElement(convertPositiveInt(src.getFrequencyMaxElement())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - tgt.setDayOfWeek(src.getDayOfWeek().stream() - .map(VersionConvertor_40_50::convertDayOfWeek) - .collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream() - .map(VersionConvertor_40_50::convertEventTiming) - .collect(Collectors.toList())); - for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t)); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); - copyElement(src, tgt); - if (src.hasBounds()) - tgt.setBounds(convertType(src.getBounds())); - if (src.hasCount()) - tgt.setCountElement(convertPositiveInt(src.getCountElement())); - if (src.hasCountMax()) - tgt.setCountMaxElement(convertPositiveInt(src.getCountMaxElement())); - if (src.hasDuration()) - tgt.setDurationElement(convertDecimal(src.getDurationElement())); - if (src.hasDurationMax()) - tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); - if (src.hasDurationUnit()) - tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); - if (src.hasFrequency()) - tgt.setFrequencyElement(convertPositiveInt(src.getFrequencyElement())); - if (src.hasFrequencyMax()) - tgt.setFrequencyMaxElement(convertPositiveInt(src.getFrequencyMaxElement())); - if (src.hasPeriod()) - tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); - if (src.hasPeriodMax()) - tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); - if (src.hasPeriodUnit()) - tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - tgt.setDayOfWeek(src.getDayOfWeek().stream() - .map(VersionConvertor_40_50::convertDayOfWeek) - .collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream() - .map(VersionConvertor_40_50::convertEventTiming) - .collect(Collectors.toList())); - for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t)); - if (src.hasOffset()) - tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case S: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); - break; - case MIN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); - break; - case H: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); - break; - case D: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); - break; - case WK: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); - break; - case MO: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); - break; - case A: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertDayOfWeek(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertDayOfWeek(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.DayOfWeekEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case MON: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.MON); - break; - case TUE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.TUE); - break; - case WED: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.WED); - break; - case THU: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.THU); - break; - case FRI: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.FRI); - break; - case SAT: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SAT); - break; - case SUN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SUN); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case MORN: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN); - break; - case MORN_EARLY: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN_EARLY); - break; - case MORN_LATE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN_LATE); - break; - case NOON: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NOON); - break; - case AFT: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT); - break; - case AFT_EARLY: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT_EARLY); - break; - case AFT_LATE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT_LATE); - break; - case EVE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE); - break; - case EVE_EARLY: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE_EARLY); - break; - case EVE_LATE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE_LATE); - break; - case NIGHT: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NIGHT); - break; - case PHS: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PHS); - break; - case HS: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case MORN: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN); - break; - case MORN_EARLY: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN_EARLY); - break; - case MORN_LATE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN_LATE); - break; - case NOON: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NOON); - break; - case AFT: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT); - break; - case AFT_EARLY: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT_EARLY); - break; - case AFT_LATE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT_LATE); - break; - case EVE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE); - break; - case EVE_EARLY: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE_EARLY); - break; - case EVE_LATE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE_LATE); - break; - case NIGHT: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NIGHT); - break; - case PHS: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PHS); - break; - case HS: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); - break; - case WAKE: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); - break; - case C: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); - break; - case CM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); - break; - case CD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); - break; - case CV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); - break; - case AC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); - break; - case ACM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); - break; - case ACD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); - break; - case ACV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); - break; - case PC: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); - break; - case PCM: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); - break; - case PCD: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); - break; - case PCV: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r4.model.TriggerDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.TriggerDefinition tgt = new org.hl7.fhir.r5.model.TriggerDefinition(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertTriggerType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - if (src.hasTiming()) - tgt.setTiming(convertType(src.getTiming())); - for (org.hl7.fhir.r4.model.DataRequirement t : src.getData()) tgt.addData(convertDataRequirement(t)); - if (src.hasCondition()) - tgt.setCondition(convertExpression(src.getCondition())); - return tgt; - } - - public static org.hl7.fhir.r4.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r5.model.TriggerDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.TriggerDefinition tgt = new org.hl7.fhir.r4.model.TriggerDefinition(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertTriggerType(src.getTypeElement())); - if (src.hasName()) - tgt.setNameElement(convertString(src.getNameElement())); - if (src.hasTiming()) - tgt.setTiming(convertType(src.getTiming())); - for (org.hl7.fhir.r5.model.DataRequirement t : src.getData()) tgt.addData(convertDataRequirement(t)); - if (src.hasCondition()) - tgt.setCondition(convertExpression(src.getCondition())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertTriggerType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TriggerDefinition.TriggerTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case NAMEDEVENT: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NAMEDEVENT); - break; - case PERIODIC: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.PERIODIC); - break; - case DATACHANGED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATACHANGED); - break; - case DATAADDED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAADDED); - break; - case DATAMODIFIED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAMODIFIED); - break; - case DATAREMOVED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAREMOVED); - break; - case DATAACCESSED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSED); - break; - case DATAACCESSENDED: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSENDED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertTriggerType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TriggerDefinition.TriggerTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case NAMEDEVENT: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NAMEDEVENT); - break; - case PERIODIC: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.PERIODIC); - break; - case DATACHANGED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATACHANGED); - break; - case DATAADDED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAADDED); - break; - case DATAMODIFIED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAMODIFIED); - break; - case DATAREMOVED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAREMOVED); - break; - case DATAACCESSED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSED); - break; - case DATAACCESSENDED: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSENDED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.UsageContext convertUsageContext(org.hl7.fhir.r4.model.UsageContext src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.UsageContext tgt = new org.hl7.fhir.r5.model.UsageContext(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(convertCoding(src.getCode())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.UsageContext convertUsageContext(org.hl7.fhir.r5.model.UsageContext src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.UsageContext tgt = new org.hl7.fhir.r4.model.UsageContext(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCode(convertCoding(src.getCode())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); - copyBackboneElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_40_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setSliceNameElement(convertString(src.getSliceNameElement())); - if (src.hasSliceIsConstraining()) - tgt.setSliceIsConstrainingElement(convertBoolean(src.getSliceIsConstrainingElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.getAlias().add(convertString(t)); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertTypeRefComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasOrderMeaning()) - tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) tgt.addExample(convertElementDefinitionExampleComponent(t)); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.getCondition().add(convertId(t)); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason()) - tgt.setIsModifierReasonElement(convertString(src.getIsModifierReasonElement())); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); - copyBackboneElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - tgt.setRepresentation(src.getRepresentation().stream() - .map(VersionConvertor_40_50::convertPropertyRepresentation) - .collect(Collectors.toList())); - if (src.hasSliceName()) - tgt.setSliceNameElement(convertString(src.getSliceNameElement())); - if (src.hasSliceIsConstraining()) - tgt.setSliceIsConstrainingElement(convertBoolean(src.getSliceIsConstrainingElement())); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); - if (src.hasSlicing()) - tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); - if (src.hasShort()) - tgt.setShortElement(convertString(src.getShortElement())); - if (src.hasDefinition()) - tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); - if (src.hasComment()) - tgt.setCommentElement(convertMarkdown(src.getCommentElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); - for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.getAlias().add(convertString(t)); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - if (src.hasBase()) - tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); - if (src.hasContentReference()) - tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); - for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) tgt.addType(convertTypeRefComponent(t)); - if (src.hasDefaultValue()) - tgt.setDefaultValue(convertType(src.getDefaultValue())); - if (src.hasMeaningWhenMissing()) - tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); - if (src.hasOrderMeaning()) - tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); - if (src.hasFixed()) - tgt.setFixed(convertType(src.getFixed())); - if (src.hasPattern()) - tgt.setPattern(convertType(src.getPattern())); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) tgt.addExample(convertElementDefinitionExampleComponent(t)); - if (src.hasMinValue()) - tgt.setMinValue(convertType(src.getMinValue())); - if (src.hasMaxValue()) - tgt.setMaxValue(convertType(src.getMaxValue())); - if (src.hasMaxLength()) - tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); - for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.getCondition().add(convertId(t)); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); - if (src.hasMustSupport()) - tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); - if (src.hasIsModifier()) - tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); - if (src.hasIsModifierReason()) - tgt.setIsModifierReasonElement(convertString(src.getIsModifierReasonElement())); - if (src.hasIsSummary()) - tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); - if (src.hasBinding()) - tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t)); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - case XHTML: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XHTML); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case XMLATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); - break; - case XMLTEXT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT); - break; - case TYPEATTR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR); - break; - case CDATEXT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT); - break; - case XHTML: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XHTML); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); - copyElement(src, tgt); - for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasOrdered()) - tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); - if (src.hasRules()) - tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case CLOSED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); - break; - case OPEN: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); - break; - case OPENATEND: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); - copyElement(src, tgt); - if (src.hasType()) - tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case VALUE: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.VALUE); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.EXISTS); - break; - case PATTERN: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PATTERN); - break; - case TYPE: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.TYPE); - break; - case PROFILE: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PROFILE); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorTypeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case VALUE: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.VALUE); - break; - case EXISTS: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.EXISTS); - break; - case PATTERN: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PATTERN); - break; - case TYPE: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.TYPE); - break; - case PROFILE: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PROFILE); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); - copyElement(src, tgt); - if (src.hasPath()) - tgt.setPathElement(convertString(src.getPathElement())); - if (src.hasMin()) - tgt.setMinElement(convertUnsignedInt(src.getMinElement())); - if (src.hasMax()) - tgt.setMaxElement(convertString(src.getMaxElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCodeElement(convertUri(src.getCodeElement())); - for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); - for (org.hl7.fhir.r4.model.CanonicalType t : src.getTargetProfile()) tgt.getTargetProfile().add(convertCanonical(t)); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_40_50::convertAggregationMode) - .collect(Collectors.toList())); - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); - copyElement(src, tgt); - if (src.hasCode()) - tgt.setCodeElement(convertUri(src.getCodeElement())); - for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); - for (org.hl7.fhir.r5.model.CanonicalType t : src.getTargetProfile()) tgt.getTargetProfile().add(convertCanonical(t)); - tgt.setAggregation(src.getAggregation().stream() - .map(VersionConvertor_40_50::convertAggregationMode) - .collect(Collectors.toList())); - if (src.hasVersioning()) - tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case CONTAINED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); - break; - case REFERENCED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); - break; - case BUNDLED: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case EITHER: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER); - break; - case INDEPENDENT: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); - break; - case SPECIFIC: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent(); - copyElement(src, tgt); - if (src.hasLabel()) - tgt.setLabelElement(convertString(src.getLabelElement())); - if (src.hasValue()) - tgt.setValue(convertType(src.getValue())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKey()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHuman()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpath()) - tgt.setXpathElement(convertString(src.getXpathElement())); - if (src.hasSource()) - tgt.setSourceElement(convertCanonical(src.getSourceElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); - copyElement(src, tgt); - if (src.hasKey()) - tgt.setKeyElement(convertId(src.getKeyElement())); - if (src.hasRequirements()) - tgt.setRequirementsElement(convertString(src.getRequirementsElement())); - if (src.hasSeverity()) - tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); - if (src.hasHuman()) - tgt.setHumanElement(convertString(src.getHumanElement())); - if (src.hasExpression()) - tgt.setExpressionElement(convertString(src.getExpressionElement())); - if (src.hasXpath()) - tgt.setXpathElement(convertString(src.getXpathElement())); - if (src.hasSource()) - tgt.setSourceElement(convertCanonical(src.getSourceElement())); - return tgt; - } - - static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { - if (src == null || src.isEmpty()) - return null; - org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); - VersionConvertor_40_50.copyElement(src, tgt); - switch(src.getValue()) { - case ERROR: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); - break; - case WARNING: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); - break; - default: - tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); - break; - } - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(Enumerations40_50.convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); - copyElement(src, tgt); - if (src.hasStrength()) - tgt.setStrengthElement(Enumerations40_50.convertBindingStrength(src.getStrengthElement())); - if (src.hasDescription()) - tgt.setDescriptionElement(convertString(src.getDescriptionElement())); - if (src.hasValueSet()) - tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentity()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMap()) - tgt.setMapElement(convertString(src.getMapElement())); - if (src.hasComment()) - tgt.setCommentElement(convertString(src.getCommentElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); - copyElement(src, tgt); - if (src.hasIdentity()) - tgt.setIdentityElement(convertId(src.getIdentityElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - if (src.hasMap()) - tgt.setMapElement(convertString(src.getMapElement())); - if (src.hasComment()) - tgt.setCommentElement(convertString(src.getCommentElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertMoneyQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertMoneyQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { - if (src == null) - return null; - org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); - copyElement(src, tgt); - if (src.hasValue()) - tgt.setValueElement(convertDecimal(src.getValueElement())); - if (src.hasComparator()) - tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); - if (src.hasUnit()) - tgt.setUnitElement(convertString(src.getUnitElement())); - if (src.hasSystem()) - tgt.setSystemElement(convertUri(src.getSystemElement())); - if (src.hasCode()) - tgt.setCodeElement(convertCode(src.getCodeElement())); - return tgt; - } - - public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r4.model.BooleanType) - return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r4.model.CanonicalType) - return convertCanonical((org.hl7.fhir.r4.model.CanonicalType) src); - if (src instanceof org.hl7.fhir.r4.model.CodeType) - return convertCode((org.hl7.fhir.r4.model.CodeType) src); - if (src instanceof org.hl7.fhir.r4.model.DateType) - return convertDate((org.hl7.fhir.r4.model.DateType) src); - if (src instanceof org.hl7.fhir.r4.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r4.model.DecimalType) - return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r4.model.IdType) - return convertId((org.hl7.fhir.r4.model.IdType) src); - if (src instanceof org.hl7.fhir.r4.model.InstantType) - return convertInstant((org.hl7.fhir.r4.model.InstantType) src); - if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r4.model.IntegerType) - return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r4.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r4.model.OidType) - return convertOid((org.hl7.fhir.r4.model.OidType) src); - if (src instanceof org.hl7.fhir.r4.model.StringType) - return convertString((org.hl7.fhir.r4.model.StringType) src); - if (src instanceof org.hl7.fhir.r4.model.TimeType) - return convertTime((org.hl7.fhir.r4.model.TimeType) src); - if (src instanceof org.hl7.fhir.r4.model.UrlType) - return convertUrl((org.hl7.fhir.r4.model.UrlType) src); - if (src instanceof org.hl7.fhir.r4.model.UuidType) - return convertUuid((org.hl7.fhir.r4.model.UuidType) src); - if (src instanceof org.hl7.fhir.r4.model.UriType) - return convertUri((org.hl7.fhir.r4.model.UriType) src); - if (src instanceof org.hl7.fhir.r4.model.Extension) - return convertExtension((org.hl7.fhir.r4.model.Extension) src); - if (src instanceof org.hl7.fhir.r4.model.Narrative) - return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); - if (src instanceof org.hl7.fhir.r4.model.Address) - return convertAddress((org.hl7.fhir.r4.model.Address) src); - if (src instanceof org.hl7.fhir.r4.model.Age) - return convertAge((org.hl7.fhir.r4.model.Age) src); - if (src instanceof org.hl7.fhir.r4.model.Annotation) - return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); - if (src instanceof org.hl7.fhir.r4.model.Attachment) - return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); - if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r4.model.Coding) - return convertCoding((org.hl7.fhir.r4.model.Coding) src); - if (src instanceof org.hl7.fhir.r4.model.ContactDetail) - return convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) src); - if (src instanceof org.hl7.fhir.r4.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r4.model.Contributor) - return convertContributor((org.hl7.fhir.r4.model.Contributor) src); - if (src instanceof org.hl7.fhir.r4.model.Count) - return convertCount((org.hl7.fhir.r4.model.Count) src); - if (src instanceof org.hl7.fhir.r4.model.DataRequirement) - return convertDataRequirement((org.hl7.fhir.r4.model.DataRequirement) src); - if (src instanceof org.hl7.fhir.r4.model.Distance) - return convertDistance((org.hl7.fhir.r4.model.Distance) src); - if (src instanceof org.hl7.fhir.r4.model.Dosage) - return convertDosage((org.hl7.fhir.r4.model.Dosage) src); - if (src instanceof org.hl7.fhir.r4.model.Duration) - return convertDuration((org.hl7.fhir.r4.model.Duration) src); - if (src instanceof org.hl7.fhir.r4.model.Expression) - return convertExpression((org.hl7.fhir.r4.model.Expression) src); - if (src instanceof org.hl7.fhir.r4.model.HumanName) - return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); - if (src instanceof org.hl7.fhir.r4.model.Identifier) - return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); - if (src instanceof org.hl7.fhir.r4.model.MarketingStatus) - return convertMarketingStatus((org.hl7.fhir.r4.model.MarketingStatus) src); - if (src instanceof org.hl7.fhir.r4.model.Meta) - return convertMeta((org.hl7.fhir.r4.model.Meta) src); - if (src instanceof org.hl7.fhir.r4.model.Money) - return convertMoney((org.hl7.fhir.r4.model.Money) src); - if (src instanceof org.hl7.fhir.r4.model.ParameterDefinition) - return convertParameterDefinition((org.hl7.fhir.r4.model.ParameterDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Period) - return convertPeriod((org.hl7.fhir.r4.model.Period) src); - if (src instanceof org.hl7.fhir.r4.model.Population) - return convertPopulation((org.hl7.fhir.r4.model.Population) src); - if (src instanceof org.hl7.fhir.r4.model.ProdCharacteristic) - return convertProdCharacteristic((org.hl7.fhir.r4.model.ProdCharacteristic) src); - if (src instanceof org.hl7.fhir.r4.model.ProductShelfLife) - return convertProductShelfLife((org.hl7.fhir.r4.model.ProductShelfLife) src); - if (src instanceof org.hl7.fhir.r4.model.MoneyQuantity) - return convertMoneyQuantity((org.hl7.fhir.r4.model.MoneyQuantity) src); - if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); - if (src instanceof org.hl7.fhir.r4.model.Quantity) - return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); - if (src instanceof org.hl7.fhir.r4.model.Range) - return convertRange((org.hl7.fhir.r4.model.Range) src); - if (src instanceof org.hl7.fhir.r4.model.Ratio) - return convertRatio((org.hl7.fhir.r4.model.Ratio) src); - if (src instanceof org.hl7.fhir.r4.model.Reference) - return convertReference((org.hl7.fhir.r4.model.Reference) src); - if (src instanceof org.hl7.fhir.r4.model.RelatedArtifact) - return convertRelatedArtifact((org.hl7.fhir.r4.model.RelatedArtifact) src); - if (src instanceof org.hl7.fhir.r4.model.SampledData) - return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); - if (src instanceof org.hl7.fhir.r4.model.Signature) - return convertSignature((org.hl7.fhir.r4.model.Signature) src); - if (src instanceof org.hl7.fhir.r4.model.SubstanceAmount) - return convertSubstanceAmount((org.hl7.fhir.r4.model.SubstanceAmount) src); - if (src instanceof org.hl7.fhir.r4.model.Timing) - return convertTiming((org.hl7.fhir.r4.model.Timing) src); - if (src instanceof org.hl7.fhir.r4.model.TriggerDefinition) - return convertTriggerDefinition((org.hl7.fhir.r4.model.TriggerDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.UsageContext) - return convertUsageContext((org.hl7.fhir.r4.model.UsageContext) src); - if (src instanceof org.hl7.fhir.r4.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) - return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); - if (src instanceof org.hl7.fhir.r5.model.BooleanType) - return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); - if (src instanceof org.hl7.fhir.r5.model.CanonicalType) - return convertCanonical((org.hl7.fhir.r5.model.CanonicalType) src); - if (src instanceof org.hl7.fhir.r5.model.CodeType) - return convertCode((org.hl7.fhir.r5.model.CodeType) src); - if (src instanceof org.hl7.fhir.r5.model.DateType) - return convertDate((org.hl7.fhir.r5.model.DateType) src); - if (src instanceof org.hl7.fhir.r5.model.DateTimeType) - return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); - if (src instanceof org.hl7.fhir.r5.model.DecimalType) - return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); - if (src instanceof org.hl7.fhir.r5.model.IdType) - return convertId((org.hl7.fhir.r5.model.IdType) src); - if (src instanceof org.hl7.fhir.r5.model.InstantType) - return convertInstant((org.hl7.fhir.r5.model.InstantType) src); - if (src instanceof org.hl7.fhir.r5.model.MarkdownType) - return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); - if (src instanceof org.hl7.fhir.r5.model.OidType) - return convertOid((org.hl7.fhir.r5.model.OidType) src); - if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) - return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); - if (src instanceof org.hl7.fhir.r5.model.StringType) - return convertString((org.hl7.fhir.r5.model.StringType) src); - if (src instanceof org.hl7.fhir.r5.model.TimeType) - return convertTime((org.hl7.fhir.r5.model.TimeType) src); - if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) - return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); - if (src instanceof org.hl7.fhir.r5.model.IntegerType) - return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); - if (src instanceof org.hl7.fhir.r5.model.UrlType) - return convertUrl((org.hl7.fhir.r5.model.UrlType) src); - if (src instanceof org.hl7.fhir.r5.model.UuidType) - return convertUuid((org.hl7.fhir.r5.model.UuidType) src); - if (src instanceof org.hl7.fhir.r5.model.UriType) - return convertUri((org.hl7.fhir.r5.model.UriType) src); - if (src instanceof org.hl7.fhir.r5.model.Extension) - return convertExtension((org.hl7.fhir.r5.model.Extension) src); - if (src instanceof org.hl7.fhir.r5.model.Narrative) - return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); - if (src instanceof org.hl7.fhir.r5.model.Address) - return convertAddress((org.hl7.fhir.r5.model.Address) src); - if (src instanceof org.hl7.fhir.r5.model.Age) - return convertAge((org.hl7.fhir.r5.model.Age) src); - if (src instanceof org.hl7.fhir.r5.model.Annotation) - return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); - if (src instanceof org.hl7.fhir.r5.model.Attachment) - return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); - if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) - return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); - if (src instanceof org.hl7.fhir.r5.model.Coding) - return convertCoding((org.hl7.fhir.r5.model.Coding) src); - if (src instanceof org.hl7.fhir.r5.model.ContactDetail) - return convertContactDetail((org.hl7.fhir.r5.model.ContactDetail) src); - if (src instanceof org.hl7.fhir.r5.model.ContactPoint) - return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); - if (src instanceof org.hl7.fhir.r5.model.Contributor) - return convertContributor((org.hl7.fhir.r5.model.Contributor) src); - if (src instanceof org.hl7.fhir.r5.model.Count) - return convertCount((org.hl7.fhir.r5.model.Count) src); - if (src instanceof org.hl7.fhir.r5.model.DataRequirement) - return convertDataRequirement((org.hl7.fhir.r5.model.DataRequirement) src); - if (src instanceof org.hl7.fhir.r5.model.Distance) - return convertDistance((org.hl7.fhir.r5.model.Distance) src); - if (src instanceof org.hl7.fhir.r5.model.Dosage) - return convertDosage((org.hl7.fhir.r5.model.Dosage) src); - if (src instanceof org.hl7.fhir.r5.model.Duration) - return convertDuration((org.hl7.fhir.r5.model.Duration) src); - if (src instanceof org.hl7.fhir.r5.model.Expression) - return convertExpression((org.hl7.fhir.r5.model.Expression) src); - if (src instanceof org.hl7.fhir.r5.model.HumanName) - return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); - if (src instanceof org.hl7.fhir.r5.model.Identifier) - return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); - if (src instanceof org.hl7.fhir.r5.model.MarketingStatus) - return convertMarketingStatus((org.hl7.fhir.r5.model.MarketingStatus) src); - if (src instanceof org.hl7.fhir.r5.model.Meta) - return convertMeta((org.hl7.fhir.r5.model.Meta) src); - if (src instanceof org.hl7.fhir.r5.model.Money) - return convertMoney((org.hl7.fhir.r5.model.Money) src); - if (src instanceof org.hl7.fhir.r5.model.ParameterDefinition) - return convertParameterDefinition((org.hl7.fhir.r5.model.ParameterDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Period) - return convertPeriod((org.hl7.fhir.r5.model.Period) src); - if (src instanceof org.hl7.fhir.r5.model.Population) - return convertPopulation((org.hl7.fhir.r5.model.Population) src); - if (src instanceof org.hl7.fhir.r5.model.ProdCharacteristic) - return convertProdCharacteristic((org.hl7.fhir.r5.model.ProdCharacteristic) src); - if (src instanceof org.hl7.fhir.r5.model.ProductShelfLife) - return convertProductShelfLife((org.hl7.fhir.r5.model.ProductShelfLife) src); - if (src instanceof org.hl7.fhir.r5.model.MoneyQuantity) - return convertMoneyQuantity((org.hl7.fhir.r5.model.MoneyQuantity) src); - if (src instanceof org.hl7.fhir.r5.model.SimpleQuantity) - return convertSimpleQuantity((org.hl7.fhir.r5.model.SimpleQuantity) src); - if (src instanceof org.hl7.fhir.r5.model.Quantity) - return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); - if (src instanceof org.hl7.fhir.r5.model.Range) - return convertRange((org.hl7.fhir.r5.model.Range) src); - if (src instanceof org.hl7.fhir.r5.model.Ratio) - return convertRatio((org.hl7.fhir.r5.model.Ratio) src); - if (src instanceof org.hl7.fhir.r5.model.Reference) - return convertReference((org.hl7.fhir.r5.model.Reference) src); - if (src instanceof org.hl7.fhir.r5.model.RelatedArtifact) - return convertRelatedArtifact((org.hl7.fhir.r5.model.RelatedArtifact) src); - if (src instanceof org.hl7.fhir.r5.model.SampledData) - return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); - if (src instanceof org.hl7.fhir.r5.model.Signature) - return convertSignature((org.hl7.fhir.r5.model.Signature) src); - if (src instanceof org.hl7.fhir.r5.model.SubstanceAmount) - return convertSubstanceAmount((org.hl7.fhir.r5.model.SubstanceAmount) src); - if (src instanceof org.hl7.fhir.r5.model.Timing) - return convertTiming((org.hl7.fhir.r5.model.Timing) src); - if (src instanceof org.hl7.fhir.r5.model.TriggerDefinition) - return convertTriggerDefinition((org.hl7.fhir.r5.model.TriggerDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.UsageContext) - return convertUsageContext((org.hl7.fhir.r5.model.UsageContext) src); - if (src instanceof org.hl7.fhir.r5.model.ElementDefinition) - return convertElementDefinition((org.hl7.fhir.r5.model.ElementDefinition) src); - throw new FHIRException("Unknown type " + src.fhirType()); - } - - protected static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); - } - - protected static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { - copyResource(src, tgt); - if (src.hasText()) - tgt.setText(convertNarrative(src.getText())); - for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); - for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); - for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); - } - - protected static void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setIdElement(convertId(src.getIdElement())); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRulesElement(convertUri(src.getImplicitRulesElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - } - - protected static void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { - if (src.hasId()) - tgt.setIdElement(convertId(src.getIdElement())); - if (src.hasMeta()) - tgt.setMeta(convertMeta(src.getMeta())); - if (src.hasImplicitRules()) - tgt.setImplicitRulesElement(convertUri(src.getImplicitRulesElement())); - if (src.hasLanguage()) - tgt.setLanguageElement(convertCode(src.getLanguageElement())); - } - - public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r4.model.Parameters) - return Parameters40_50.convertParameters((org.hl7.fhir.r4.model.Parameters) src); - if (src instanceof org.hl7.fhir.r4.model.Account) - return Account40_50.convertAccount((org.hl7.fhir.r4.model.Account) src); - if (src instanceof org.hl7.fhir.r4.model.ActivityDefinition) - return ActivityDefinition40_50.convertActivityDefinition((org.hl7.fhir.r4.model.ActivityDefinition) src); - // if (src instanceof org.hl7.fhir.r4.model.AdverseEvent) - // return AdverseEvent.convertAdverseEvent((org.hl7.fhir.r4.model.AdverseEvent) src); - if (src instanceof org.hl7.fhir.r4.model.AllergyIntolerance) - return AllergyIntolerance40_50.convertAllergyIntolerance((org.hl7.fhir.r4.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.r4.model.Appointment) - return Appointment40_50.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); - if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) - return AppointmentResponse40_50.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.r4.model.AuditEvent) - return AuditEvent40_50.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.r4.model.Basic) - return Basic40_50.convertBasic((org.hl7.fhir.r4.model.Basic) src); - if (src instanceof org.hl7.fhir.r4.model.Binary) - return Binary40_50.convertBinary((org.hl7.fhir.r4.model.Binary) src); - if (src instanceof org.hl7.fhir.r4.model.BiologicallyDerivedProduct) - return BiologicallyDerivedProduct40_50.convertBiologicallyDerivedProduct((org.hl7.fhir.r4.model.BiologicallyDerivedProduct) src); - if (src instanceof org.hl7.fhir.r4.model.BodyStructure) - return BodyStructure40_50.convertBodyStructure((org.hl7.fhir.r4.model.BodyStructure) src); - if (src instanceof org.hl7.fhir.r4.model.Bundle) - return Bundle40_50.convertBundle((org.hl7.fhir.r4.model.Bundle) src); - if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) - return CapabilityStatement40_50.convertCapabilityStatement((org.hl7.fhir.r4.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r4.model.CarePlan) - return CarePlan40_50.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); - if (src instanceof org.hl7.fhir.r4.model.CareTeam) - return CareTeam40_50.convertCareTeam((org.hl7.fhir.r4.model.CareTeam) src); - // if (src instanceof org.hl7.fhir.r4.model.CatalogEntry) - // return CatalogEntry.convertCatalogEntry((org.hl7.fhir.r4.model.CatalogEntry) src); - if (src instanceof org.hl7.fhir.r4.model.ChargeItem) - return ChargeItem40_50.convertChargeItem((org.hl7.fhir.r4.model.ChargeItem) src); - if (src instanceof org.hl7.fhir.r4.model.ChargeItemDefinition) - return ChargeItemDefinition40_50.convertChargeItemDefinition((org.hl7.fhir.r4.model.ChargeItemDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Claim) - return Claim40_50.convertClaim((org.hl7.fhir.r4.model.Claim) src); - if (src instanceof org.hl7.fhir.r4.model.ClaimResponse) - return ClaimResponse40_50.convertClaimResponse((org.hl7.fhir.r4.model.ClaimResponse) src); - if (src instanceof org.hl7.fhir.r4.model.ClinicalImpression) - return ClinicalImpression40_50.convertClinicalImpression((org.hl7.fhir.r4.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.r4.model.CodeSystem) - return CodeSystem40_50.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.r4.model.Communication) - return Communication40_50.convertCommunication((org.hl7.fhir.r4.model.Communication) src); - if (src instanceof org.hl7.fhir.r4.model.CommunicationRequest) - return CommunicationRequest40_50.convertCommunicationRequest((org.hl7.fhir.r4.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) - return CompartmentDefinition40_50.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Composition) - return Composition40_50.convertComposition((org.hl7.fhir.r4.model.Composition) src); - if (src instanceof org.hl7.fhir.r4.model.ConceptMap) - return ConceptMap40_50.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r4.model.Condition) - return Condition40_50.convertCondition((org.hl7.fhir.r4.model.Condition) src); - if (src instanceof org.hl7.fhir.r4.model.Consent) - return Consent40_50.convertConsent((org.hl7.fhir.r4.model.Consent) src); - if (src instanceof org.hl7.fhir.r4.model.Contract) - return Contract40_50.convertContract((org.hl7.fhir.r4.model.Contract) src); - if (src instanceof org.hl7.fhir.r4.model.Coverage) - return Coverage40_50.convertCoverage((org.hl7.fhir.r4.model.Coverage) src); - if (src instanceof org.hl7.fhir.r4.model.CoverageEligibilityRequest) - return CoverageEligibilityRequest40_50.convertCoverageEligibilityRequest((org.hl7.fhir.r4.model.CoverageEligibilityRequest) src); - if (src instanceof org.hl7.fhir.r4.model.CoverageEligibilityResponse) - return CoverageEligibilityResponse40_50.convertCoverageEligibilityResponse((org.hl7.fhir.r4.model.CoverageEligibilityResponse) src); - if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) - return DetectedIssue40_50.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.r4.model.Device) - return Device40_50.convertDevice((org.hl7.fhir.r4.model.Device) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceDefinition) - return DeviceDefinition40_50.convertDeviceDefinition((org.hl7.fhir.r4.model.DeviceDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceMetric) - return DeviceMetric40_50.convertDeviceMetric((org.hl7.fhir.r4.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceRequest) - return DeviceRequest40_50.convertDeviceRequest((org.hl7.fhir.r4.model.DeviceRequest) src); - if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) - return DeviceUseStatement40_50.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) - return DiagnosticReport40_50.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.r4.model.DocumentManifest) - return DocumentManifest40_50.convertDocumentManifest((org.hl7.fhir.r4.model.DocumentManifest) src); - if (src instanceof org.hl7.fhir.r4.model.DocumentReference) - return DocumentReference40_50.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r4.model.Encounter) - return Encounter40_50.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); - if (src instanceof org.hl7.fhir.r4.model.Endpoint) - return Endpoint40_50.convertEndpoint((org.hl7.fhir.r4.model.Endpoint) src); - if (src instanceof org.hl7.fhir.r4.model.EnrollmentRequest) - return EnrollmentRequest40_50.convertEnrollmentRequest((org.hl7.fhir.r4.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.r4.model.EnrollmentResponse) - return EnrollmentResponse40_50.convertEnrollmentResponse((org.hl7.fhir.r4.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) - return EpisodeOfCare40_50.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.r4.model.EventDefinition) - return EventDefinition40_50.convertEventDefinition((org.hl7.fhir.r4.model.EventDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.ExampleScenario) - return ExampleScenario40_50.convertExampleScenario((org.hl7.fhir.r4.model.ExampleScenario) src); - if (src instanceof org.hl7.fhir.r4.model.ExplanationOfBenefit) - return ExplanationOfBenefit40_50.convertExplanationOfBenefit((org.hl7.fhir.r4.model.ExplanationOfBenefit) src); - if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) - return FamilyMemberHistory40_50.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.r4.model.Flag) - return Flag40_50.convertFlag((org.hl7.fhir.r4.model.Flag) src); - if (src instanceof org.hl7.fhir.r4.model.Goal) - return Goal40_50.convertGoal((org.hl7.fhir.r4.model.Goal) src); - if (src instanceof org.hl7.fhir.r4.model.GraphDefinition) - return GraphDefinition40_50.convertGraphDefinition((org.hl7.fhir.r4.model.GraphDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Group) - return Group40_50.convertGroup((org.hl7.fhir.r4.model.Group) src); - if (src instanceof org.hl7.fhir.r4.model.GuidanceResponse) - return GuidanceResponse40_50.convertGuidanceResponse((org.hl7.fhir.r4.model.GuidanceResponse) src); - if (src instanceof org.hl7.fhir.r4.model.HealthcareService) - return HealthcareService40_50.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.r4.model.ImagingStudy) - return ImagingStudy40_50.convertImagingStudy((org.hl7.fhir.r4.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.r4.model.Immunization) - return Immunization40_50.convertImmunization((org.hl7.fhir.r4.model.Immunization) src); - if (src instanceof org.hl7.fhir.r4.model.ImmunizationEvaluation) - return ImmunizationEvaluation40_50.convertImmunizationEvaluation((org.hl7.fhir.r4.model.ImmunizationEvaluation) src); - if (src instanceof org.hl7.fhir.r4.model.ImmunizationRecommendation) - return ImmunizationRecommendation40_50.convertImmunizationRecommendation((org.hl7.fhir.r4.model.ImmunizationRecommendation) src); - if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) - return ImplementationGuide40_50.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r4.model.InsurancePlan) - return InsurancePlan40_50.convertInsurancePlan((org.hl7.fhir.r4.model.InsurancePlan) src); - if (src instanceof org.hl7.fhir.r4.model.Invoice) - return Invoice40_50.convertInvoice((org.hl7.fhir.r4.model.Invoice) src); - if (src instanceof org.hl7.fhir.r4.model.Library) - return Library40_50.convertLibrary((org.hl7.fhir.r4.model.Library) src); - if (src instanceof org.hl7.fhir.r4.model.Linkage) - return Linkage40_50.convertLinkage((org.hl7.fhir.r4.model.Linkage) src); - if (src instanceof org.hl7.fhir.r4.model.ListResource) - return ListResource40_50.convertListResource((org.hl7.fhir.r4.model.ListResource) src); - if (src instanceof org.hl7.fhir.r4.model.Location) - return Location40_50.convertLocation((org.hl7.fhir.r4.model.Location) src); - if (src instanceof org.hl7.fhir.r4.model.Measure) - return Measure40_50.convertMeasure((org.hl7.fhir.r4.model.Measure) src); - if (src instanceof org.hl7.fhir.r4.model.MeasureReport) - return MeasureReport40_50.convertMeasureReport((org.hl7.fhir.r4.model.MeasureReport) src); - if (src instanceof org.hl7.fhir.r4.model.Media) - return Media40_50.convertMedia((org.hl7.fhir.r4.model.Media) src); - if (src instanceof org.hl7.fhir.r4.model.Medication) - return Medication40_50.convertMedication((org.hl7.fhir.r4.model.Medication) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationAdministration) - return MedicationAdministration40_50.convertMedicationAdministration((org.hl7.fhir.r4.model.MedicationAdministration) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) - return MedicationDispense40_50.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationKnowledge) - return MedicationKnowledge40_50.convertMedicationKnowledge((org.hl7.fhir.r4.model.MedicationKnowledge) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationRequest) - return MedicationRequest40_50.convertMedicationRequest((org.hl7.fhir.r4.model.MedicationRequest) src); - if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) - return MedicationStatement40_50.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); - if (src instanceof org.hl7.fhir.r4.model.MedicinalProduct) - return MedicinalProductDefinition40_50.convertMedicinalProduct((org.hl7.fhir.r4.model.MedicinalProduct) src); - if (src instanceof org.hl7.fhir.r4.model.MessageDefinition) - return MessageDefinition40_50.convertMessageDefinition((org.hl7.fhir.r4.model.MessageDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.MessageHeader) - return MessageHeader40_50.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.r4.model.MolecularSequence) - return MolecularSequence40_50.convertMolecularSequence((org.hl7.fhir.r4.model.MolecularSequence) src); - if (src instanceof org.hl7.fhir.r4.model.NamingSystem) - return NamingSystem40_50.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r4.model.NutritionOrder) - return NutritionOrder40_50.convertNutritionOrder((org.hl7.fhir.r4.model.NutritionOrder) src); - if (src instanceof org.hl7.fhir.r4.model.Observation) - return Observation40_50.convertObservation((org.hl7.fhir.r4.model.Observation) src); - if (src instanceof org.hl7.fhir.r4.model.ObservationDefinition) - return ObservationDefinition40_50.convertObservationDefinition((org.hl7.fhir.r4.model.ObservationDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) - return OperationDefinition40_50.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) - return OperationOutcome40_50.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r4.model.Organization) - return Organization40_50.convertOrganization((org.hl7.fhir.r4.model.Organization) src); - if (src instanceof org.hl7.fhir.r4.model.OrganizationAffiliation) - return OrganizationAffiliation40_50.convertOrganizationAffiliation((org.hl7.fhir.r4.model.OrganizationAffiliation) src); - if (src instanceof org.hl7.fhir.r4.model.Patient) - return Patient40_50.convertPatient((org.hl7.fhir.r4.model.Patient) src); - if (src instanceof org.hl7.fhir.r4.model.PaymentNotice) - return PaymentNotice40_50.convertPaymentNotice((org.hl7.fhir.r4.model.PaymentNotice) src); - if (src instanceof org.hl7.fhir.r4.model.PaymentReconciliation) - return PaymentReconciliation40_50.convertPaymentReconciliation((org.hl7.fhir.r4.model.PaymentReconciliation) src); - if (src instanceof org.hl7.fhir.r4.model.Person) - return Person40_50.convertPerson((org.hl7.fhir.r4.model.Person) src); - if (src instanceof org.hl7.fhir.r4.model.PlanDefinition) - return PlanDefinition40_50.convertPlanDefinition((org.hl7.fhir.r4.model.PlanDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.Practitioner) - return Practitioner40_50.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); - if (src instanceof org.hl7.fhir.r4.model.PractitionerRole) - return PractitionerRole40_50.convertPractitionerRole((org.hl7.fhir.r4.model.PractitionerRole) src); - if (src instanceof org.hl7.fhir.r4.model.Procedure) - return Procedure40_50.convertProcedure((org.hl7.fhir.r4.model.Procedure) src); - if (src instanceof org.hl7.fhir.r4.model.Provenance) - return Provenance40_50.convertProvenance((org.hl7.fhir.r4.model.Provenance) src); - if (src instanceof org.hl7.fhir.r4.model.Questionnaire) - return Questionnaire40_50.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) - return QuestionnaireResponse40_50.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r4.model.RelatedPerson) - return RelatedPerson40_50.convertRelatedPerson((org.hl7.fhir.r4.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.r4.model.RequestGroup) - return RequestGroup40_50.convertRequestGroup((org.hl7.fhir.r4.model.RequestGroup) src); - if (src instanceof org.hl7.fhir.r4.model.ResearchStudy) - return ResearchStudy40_50.convertResearchStudy((org.hl7.fhir.r4.model.ResearchStudy) src); - if (src instanceof org.hl7.fhir.r4.model.ResearchSubject) - return ResearchSubject40_50.convertResearchSubject((org.hl7.fhir.r4.model.ResearchSubject) src); - if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) - return RiskAssessment40_50.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.r4.model.Schedule) - return Schedule40_50.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); - if (src instanceof org.hl7.fhir.r4.model.SearchParameter) - return SearchParameter40_50.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r4.model.ServiceRequest) - return ServiceRequest40_50.convertServiceRequest((org.hl7.fhir.r4.model.ServiceRequest) src); - if (src instanceof org.hl7.fhir.r4.model.Slot) - return Slot40_50.convertSlot((org.hl7.fhir.r4.model.Slot) src); - if (src instanceof org.hl7.fhir.r4.model.Specimen) - return Specimen40_50.convertSpecimen((org.hl7.fhir.r4.model.Specimen) src); - if (src instanceof org.hl7.fhir.r4.model.SpecimenDefinition) - return SpecimenDefinition40_50.convertSpecimenDefinition((org.hl7.fhir.r4.model.SpecimenDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) - return StructureDefinition40_50.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r4.model.StructureMap) - return StructureMap40_50.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); - // if (src instanceof org.hl7.fhir.r4.model.Subscription) - // return Subscription.convertSubscription((org.hl7.fhir.r4.model.Subscription) src); - if (src instanceof org.hl7.fhir.r4.model.Substance) - return Substance40_50.convertSubstance((org.hl7.fhir.r4.model.Substance) src); - if (src instanceof org.hl7.fhir.r4.model.SubstanceNucleicAcid) - return SubstanceNucleicAcid40_50.convertSubstanceNucleicAcid((org.hl7.fhir.r4.model.SubstanceNucleicAcid) src); - if (src instanceof org.hl7.fhir.r4.model.SubstancePolymer) - return SubstancePolymer40_50.convertSubstancePolymer((org.hl7.fhir.r4.model.SubstancePolymer) src); - if (src instanceof org.hl7.fhir.r4.model.SubstanceProtein) - return SubstanceProtein40_50.convertSubstanceProtein((org.hl7.fhir.r4.model.SubstanceProtein) src); - if (src instanceof org.hl7.fhir.r4.model.SubstanceReferenceInformation) - return SubstanceReferenceInformation40_50.convertSubstanceReferenceInformation((org.hl7.fhir.r4.model.SubstanceReferenceInformation) src); - if (src instanceof org.hl7.fhir.r4.model.SubstanceSourceMaterial) - return SubstanceSourceMaterial40_50.convertSubstanceSourceMaterial((org.hl7.fhir.r4.model.SubstanceSourceMaterial) src); - if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) - return SupplyDelivery40_50.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.r4.model.SupplyRequest) - return SupplyRequest40_50.convertSupplyRequest((org.hl7.fhir.r4.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.r4.model.Task) - return Task40_50.convertTask((org.hl7.fhir.r4.model.Task) src); - if (src instanceof org.hl7.fhir.r4.model.TerminologyCapabilities) - return TerminologyCapabilities40_50.convertTerminologyCapabilities((org.hl7.fhir.r4.model.TerminologyCapabilities) src); - if (src instanceof org.hl7.fhir.r4.model.TestReport) - return TestReport40_50.convertTestReport((org.hl7.fhir.r4.model.TestReport) src); - if (src instanceof org.hl7.fhir.r4.model.TestScript) - return TestScript40_50.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); - if (src instanceof org.hl7.fhir.r4.model.ValueSet) - return ValueSet40_50.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); - if (src instanceof org.hl7.fhir.r4.model.VerificationResult) - return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r4.model.VerificationResult) src); - if (src instanceof org.hl7.fhir.r4.model.VisionPrescription) - return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r4.model.VisionPrescription) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { - if (src == null) - return null; - if (src instanceof org.hl7.fhir.r5.model.Parameters) - return Parameters40_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); - if (src instanceof org.hl7.fhir.r5.model.Account) - return Account40_50.convertAccount((org.hl7.fhir.r5.model.Account) src); - if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition) - return ActivityDefinition40_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src); - // if (src instanceof org.hl7.fhir.r5.model.AdverseEvent) - // return AdverseEvent.convertAdverseEvent((org.hl7.fhir.r5.model.AdverseEvent) src); - if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance) - return AllergyIntolerance40_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src); - if (src instanceof org.hl7.fhir.r5.model.Appointment) - return Appointment40_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); - if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) - return AppointmentResponse40_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); - if (src instanceof org.hl7.fhir.r5.model.AuditEvent) - return AuditEvent40_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); - if (src instanceof org.hl7.fhir.r5.model.Basic) - return Basic40_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); - if (src instanceof org.hl7.fhir.r5.model.Binary) - return Binary40_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); - if (src instanceof org.hl7.fhir.r5.model.BiologicallyDerivedProduct) - return BiologicallyDerivedProduct40_50.convertBiologicallyDerivedProduct((org.hl7.fhir.r5.model.BiologicallyDerivedProduct) src); - if (src instanceof org.hl7.fhir.r5.model.BodyStructure) - return BodyStructure40_50.convertBodyStructure((org.hl7.fhir.r5.model.BodyStructure) src); - if (src instanceof org.hl7.fhir.r5.model.Bundle) - return Bundle40_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src); - if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) - return CapabilityStatement40_50.convertCapabilityStatement((org.hl7.fhir.r5.model.CapabilityStatement) src); - if (src instanceof org.hl7.fhir.r5.model.CarePlan) - return CarePlan40_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); - if (src instanceof org.hl7.fhir.r5.model.CareTeam) - return CareTeam40_50.convertCareTeam((org.hl7.fhir.r5.model.CareTeam) src); - // if (src instanceof org.hl7.fhir.r5.model.CatalogEntry) - // return CatalogEntry.convertCatalogEntry((org.hl7.fhir.r5.model.CatalogEntry) src); - if (src instanceof org.hl7.fhir.r5.model.ChargeItem) - return ChargeItem40_50.convertChargeItem((org.hl7.fhir.r5.model.ChargeItem) src); - if (src instanceof org.hl7.fhir.r5.model.ChargeItemDefinition) - return ChargeItemDefinition40_50.convertChargeItemDefinition((org.hl7.fhir.r5.model.ChargeItemDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Claim) - return Claim40_50.convertClaim((org.hl7.fhir.r5.model.Claim) src); - if (src instanceof org.hl7.fhir.r5.model.ClaimResponse) - return ClaimResponse40_50.convertClaimResponse((org.hl7.fhir.r5.model.ClaimResponse) src); - if (src instanceof org.hl7.fhir.r5.model.ClinicalImpression) - return ClinicalImpression40_50.convertClinicalImpression((org.hl7.fhir.r5.model.ClinicalImpression) src); - if (src instanceof org.hl7.fhir.r5.model.CodeSystem) - return CodeSystem40_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src); - if (src instanceof org.hl7.fhir.r5.model.Communication) - return Communication40_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); - if (src instanceof org.hl7.fhir.r5.model.CommunicationRequest) - return CommunicationRequest40_50.convertCommunicationRequest((org.hl7.fhir.r5.model.CommunicationRequest) src); - if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition) - return CompartmentDefinition40_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Composition) - return Composition40_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); - if (src instanceof org.hl7.fhir.r5.model.ConceptMap) - return ConceptMap40_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); - if (src instanceof org.hl7.fhir.r5.model.Condition) - return Condition40_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); - if (src instanceof org.hl7.fhir.r5.model.Consent) - return Consent40_50.convertConsent((org.hl7.fhir.r5.model.Consent) src); - if (src instanceof org.hl7.fhir.r5.model.Contract) - return Contract40_50.convertContract((org.hl7.fhir.r5.model.Contract) src); - if (src instanceof org.hl7.fhir.r5.model.Coverage) - return Coverage40_50.convertCoverage((org.hl7.fhir.r5.model.Coverage) src); - if (src instanceof org.hl7.fhir.r5.model.CoverageEligibilityRequest) - return CoverageEligibilityRequest40_50.convertCoverageEligibilityRequest((org.hl7.fhir.r5.model.CoverageEligibilityRequest) src); - if (src instanceof org.hl7.fhir.r5.model.CoverageEligibilityResponse) - return CoverageEligibilityResponse40_50.convertCoverageEligibilityResponse((org.hl7.fhir.r5.model.CoverageEligibilityResponse) src); - if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) - return DetectedIssue40_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); - if (src instanceof org.hl7.fhir.r5.model.Device) - return Device40_50.convertDevice((org.hl7.fhir.r5.model.Device) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceDefinition) - return DeviceDefinition40_50.convertDeviceDefinition((org.hl7.fhir.r5.model.DeviceDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceMetric) - return DeviceMetric40_50.convertDeviceMetric((org.hl7.fhir.r5.model.DeviceMetric) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceRequest) - return DeviceRequest40_50.convertDeviceRequest((org.hl7.fhir.r5.model.DeviceRequest) src); - if (src instanceof org.hl7.fhir.r5.model.DeviceUseStatement) - return DeviceUseStatement40_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUseStatement) src); - if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) - return DiagnosticReport40_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); - if (src instanceof org.hl7.fhir.r5.model.DocumentManifest) - return DocumentManifest40_50.convertDocumentManifest((org.hl7.fhir.r5.model.DocumentManifest) src); - if (src instanceof org.hl7.fhir.r5.model.DocumentReference) - return DocumentReference40_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r5.model.Encounter) - return Encounter40_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); - if (src instanceof org.hl7.fhir.r5.model.Endpoint) - return Endpoint40_50.convertEndpoint((org.hl7.fhir.r5.model.Endpoint) src); - if (src instanceof org.hl7.fhir.r5.model.EnrollmentRequest) - return EnrollmentRequest40_50.convertEnrollmentRequest((org.hl7.fhir.r5.model.EnrollmentRequest) src); - if (src instanceof org.hl7.fhir.r5.model.EnrollmentResponse) - return EnrollmentResponse40_50.convertEnrollmentResponse((org.hl7.fhir.r5.model.EnrollmentResponse) src); - if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) - return EpisodeOfCare40_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); - if (src instanceof org.hl7.fhir.r5.model.EventDefinition) - return EventDefinition40_50.convertEventDefinition((org.hl7.fhir.r5.model.EventDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.ExampleScenario) - return ExampleScenario40_50.convertExampleScenario((org.hl7.fhir.r5.model.ExampleScenario) src); - if (src instanceof org.hl7.fhir.r5.model.ExplanationOfBenefit) - return ExplanationOfBenefit40_50.convertExplanationOfBenefit((org.hl7.fhir.r5.model.ExplanationOfBenefit) src); - if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) - return FamilyMemberHistory40_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); - if (src instanceof org.hl7.fhir.r5.model.Flag) - return Flag40_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); - if (src instanceof org.hl7.fhir.r5.model.Goal) - return Goal40_50.convertGoal((org.hl7.fhir.r5.model.Goal) src); - if (src instanceof org.hl7.fhir.r5.model.GraphDefinition) - return GraphDefinition40_50.convertGraphDefinition((org.hl7.fhir.r5.model.GraphDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Group) - return Group40_50.convertGroup((org.hl7.fhir.r5.model.Group) src); - if (src instanceof org.hl7.fhir.r5.model.GuidanceResponse) - return GuidanceResponse40_50.convertGuidanceResponse((org.hl7.fhir.r5.model.GuidanceResponse) src); - if (src instanceof org.hl7.fhir.r5.model.HealthcareService) - return HealthcareService40_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); - if (src instanceof org.hl7.fhir.r5.model.ImagingStudy) - return ImagingStudy40_50.convertImagingStudy((org.hl7.fhir.r5.model.ImagingStudy) src); - if (src instanceof org.hl7.fhir.r5.model.Immunization) - return Immunization40_50.convertImmunization((org.hl7.fhir.r5.model.Immunization) src); - if (src instanceof org.hl7.fhir.r5.model.ImmunizationEvaluation) - return ImmunizationEvaluation40_50.convertImmunizationEvaluation((org.hl7.fhir.r5.model.ImmunizationEvaluation) src); - if (src instanceof org.hl7.fhir.r5.model.ImmunizationRecommendation) - return ImmunizationRecommendation40_50.convertImmunizationRecommendation((org.hl7.fhir.r5.model.ImmunizationRecommendation) src); - if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) - return ImplementationGuide40_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); - if (src instanceof org.hl7.fhir.r5.model.InsurancePlan) - return InsurancePlan40_50.convertInsurancePlan((org.hl7.fhir.r5.model.InsurancePlan) src); - if (src instanceof org.hl7.fhir.r5.model.Invoice) - return Invoice40_50.convertInvoice((org.hl7.fhir.r5.model.Invoice) src); - if (src instanceof org.hl7.fhir.r5.model.Library) - return Library40_50.convertLibrary((org.hl7.fhir.r5.model.Library) src); - if (src instanceof org.hl7.fhir.r5.model.Linkage) - return Linkage40_50.convertLinkage((org.hl7.fhir.r5.model.Linkage) src); - if (src instanceof org.hl7.fhir.r5.model.ListResource) - return ListResource40_50.convertListResource((org.hl7.fhir.r5.model.ListResource) src); - if (src instanceof org.hl7.fhir.r5.model.Location) - return Location40_50.convertLocation((org.hl7.fhir.r5.model.Location) src); - if (src instanceof org.hl7.fhir.r5.model.Measure) - return Measure40_50.convertMeasure((org.hl7.fhir.r5.model.Measure) src); - if (src instanceof org.hl7.fhir.r5.model.MeasureReport) - return MeasureReport40_50.convertMeasureReport((org.hl7.fhir.r5.model.MeasureReport) src); - if (// todo: will never get here (doesn't work anyway) - src instanceof org.hl7.fhir.r5.model.DocumentReference) - return Media40_50.convertMedia((org.hl7.fhir.r5.model.DocumentReference) src); - if (src instanceof org.hl7.fhir.r5.model.Medication) - return Medication40_50.convertMedication((org.hl7.fhir.r5.model.Medication) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationAdministration) - return MedicationAdministration40_50.convertMedicationAdministration((org.hl7.fhir.r5.model.MedicationAdministration) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) - return MedicationDispense40_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationKnowledge) - return MedicationKnowledge40_50.convertMedicationKnowledge((org.hl7.fhir.r5.model.MedicationKnowledge) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationRequest) - return MedicationRequest40_50.convertMedicationRequest((org.hl7.fhir.r5.model.MedicationRequest) src); - if (src instanceof org.hl7.fhir.r5.model.MedicationUsage) - return MedicationStatement40_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationUsage) src); - if (src instanceof org.hl7.fhir.r5.model.MedicinalProductDefinition) - return MedicinalProductDefinition40_50.convertMedicinalProductDefinition((org.hl7.fhir.r5.model.MedicinalProductDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.MessageDefinition) - return MessageDefinition40_50.convertMessageDefinition((org.hl7.fhir.r5.model.MessageDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.MessageHeader) - return MessageHeader40_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); - if (src instanceof org.hl7.fhir.r5.model.MolecularSequence) - return MolecularSequence40_50.convertMolecularSequence((org.hl7.fhir.r5.model.MolecularSequence) src); - if (src instanceof org.hl7.fhir.r5.model.NamingSystem) - return NamingSystem40_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); - if (src instanceof org.hl7.fhir.r5.model.NutritionOrder) - return NutritionOrder40_50.convertNutritionOrder((org.hl7.fhir.r5.model.NutritionOrder) src); - if (src instanceof org.hl7.fhir.r5.model.Observation) - return Observation40_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); - if (src instanceof org.hl7.fhir.r5.model.ObservationDefinition) - return ObservationDefinition40_50.convertObservationDefinition((org.hl7.fhir.r5.model.ObservationDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) - return OperationDefinition40_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) - return OperationOutcome40_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); - if (src instanceof org.hl7.fhir.r5.model.Organization) - return Organization40_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); - if (src instanceof org.hl7.fhir.r5.model.OrganizationAffiliation) - return OrganizationAffiliation40_50.convertOrganizationAffiliation((org.hl7.fhir.r5.model.OrganizationAffiliation) src); - if (src instanceof org.hl7.fhir.r5.model.Patient) - return Patient40_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); - if (src instanceof org.hl7.fhir.r5.model.PaymentNotice) - return PaymentNotice40_50.convertPaymentNotice((org.hl7.fhir.r5.model.PaymentNotice) src); - if (src instanceof org.hl7.fhir.r5.model.PaymentReconciliation) - return PaymentReconciliation40_50.convertPaymentReconciliation((org.hl7.fhir.r5.model.PaymentReconciliation) src); - if (src instanceof org.hl7.fhir.r5.model.Person) - return Person40_50.convertPerson((org.hl7.fhir.r5.model.Person) src); - if (src instanceof org.hl7.fhir.r5.model.PlanDefinition) - return PlanDefinition40_50.convertPlanDefinition((org.hl7.fhir.r5.model.PlanDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.Practitioner) - return Practitioner40_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); - if (src instanceof org.hl7.fhir.r5.model.PractitionerRole) - return PractitionerRole40_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src); - if (src instanceof org.hl7.fhir.r5.model.Procedure) - return Procedure40_50.convertProcedure((org.hl7.fhir.r5.model.Procedure) src); - if (src instanceof org.hl7.fhir.r5.model.Provenance) - return Provenance40_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); - if (src instanceof org.hl7.fhir.r5.model.Questionnaire) - return Questionnaire40_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); - if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) - return QuestionnaireResponse40_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); - if (src instanceof org.hl7.fhir.r5.model.RelatedPerson) - return RelatedPerson40_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src); - if (src instanceof org.hl7.fhir.r5.model.RequestGroup) - return RequestGroup40_50.convertRequestGroup((org.hl7.fhir.r5.model.RequestGroup) src); - if (src instanceof org.hl7.fhir.r5.model.ResearchStudy) - return ResearchStudy40_50.convertResearchStudy((org.hl7.fhir.r5.model.ResearchStudy) src); - if (src instanceof org.hl7.fhir.r5.model.ResearchSubject) - return ResearchSubject40_50.convertResearchSubject((org.hl7.fhir.r5.model.ResearchSubject) src); - if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) - return RiskAssessment40_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); - if (src instanceof org.hl7.fhir.r5.model.Schedule) - return Schedule40_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); - if (src instanceof org.hl7.fhir.r5.model.SearchParameter) - return SearchParameter40_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); - if (src instanceof org.hl7.fhir.r5.model.ServiceRequest) - return ServiceRequest40_50.convertServiceRequest((org.hl7.fhir.r5.model.ServiceRequest) src); - if (src instanceof org.hl7.fhir.r5.model.Slot) - return Slot40_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); - if (src instanceof org.hl7.fhir.r5.model.Specimen) - return Specimen40_50.convertSpecimen((org.hl7.fhir.r5.model.Specimen) src); - if (src instanceof org.hl7.fhir.r5.model.SpecimenDefinition) - return SpecimenDefinition40_50.convertSpecimenDefinition((org.hl7.fhir.r5.model.SpecimenDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) - return StructureDefinition40_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); - if (src instanceof org.hl7.fhir.r5.model.StructureMap) - return StructureMap40_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src); - // if (src instanceof org.hl7.fhir.r5.model.Subscription) - // return Subscription.convertSubscription((org.hl7.fhir.r5.model.Subscription) src); - if (src instanceof org.hl7.fhir.r5.model.Substance) - return Substance40_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); - if (src instanceof org.hl7.fhir.r5.model.SubstanceNucleicAcid) - return SubstanceNucleicAcid40_50.convertSubstanceNucleicAcid((org.hl7.fhir.r5.model.SubstanceNucleicAcid) src); - if (src instanceof org.hl7.fhir.r5.model.SubstancePolymer) - return SubstancePolymer40_50.convertSubstancePolymer((org.hl7.fhir.r5.model.SubstancePolymer) src); - if (src instanceof org.hl7.fhir.r5.model.SubstanceProtein) - return SubstanceProtein40_50.convertSubstanceProtein((org.hl7.fhir.r5.model.SubstanceProtein) src); - if (src instanceof org.hl7.fhir.r5.model.SubstanceReferenceInformation) - return SubstanceReferenceInformation40_50.convertSubstanceReferenceInformation((org.hl7.fhir.r5.model.SubstanceReferenceInformation) src); - if (src instanceof org.hl7.fhir.r5.model.SubstanceSourceMaterial) - return SubstanceSourceMaterial40_50.convertSubstanceSourceMaterial((org.hl7.fhir.r5.model.SubstanceSourceMaterial) src); - if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) - return SupplyDelivery40_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); - if (src instanceof org.hl7.fhir.r5.model.SupplyRequest) - return SupplyRequest40_50.convertSupplyRequest((org.hl7.fhir.r5.model.SupplyRequest) src); - if (src instanceof org.hl7.fhir.r5.model.Task) - return Task40_50.convertTask((org.hl7.fhir.r5.model.Task) src); - if (src instanceof org.hl7.fhir.r5.model.TerminologyCapabilities) - return TerminologyCapabilities40_50.convertTerminologyCapabilities((org.hl7.fhir.r5.model.TerminologyCapabilities) src); - if (src instanceof org.hl7.fhir.r5.model.TestReport) - return TestReport40_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); - if (src instanceof org.hl7.fhir.r5.model.TestScript) - return TestScript40_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); - if (src instanceof org.hl7.fhir.r5.model.ValueSet) - return ValueSet40_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); - if (src instanceof org.hl7.fhir.r5.model.VerificationResult) - return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r5.model.VerificationResult) src); - if (src instanceof org.hl7.fhir.r5.model.VisionPrescription) - return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r5.model.VisionPrescription) src); - throw new FHIRException("Unknown resource " + src.fhirType()); - } - - protected static org.hl7.fhir.r5.model.CodeType convertResourceEnum(org.hl7.fhir.r4.model.CodeType src) { - return convertCode(src); - } - - protected static org.hl7.fhir.r4.model.CodeType convertResourceEnum(org.hl7.fhir.r5.model.CodeType src) { - return convertCode(src); - } - - protected static CodeableReference convertReferenceToCodeableReference(org.hl7.fhir.r4.model.Reference src) { - CodeableReference tgt = new CodeableReference(); - tgt.setReference(convertReference(src)); - return tgt; - } - - protected static CodeableReference convertCodeableConceptToCodeableReference(org.hl7.fhir.r4.model.CodeableConcept src) { - CodeableReference tgt = new CodeableReference(); - tgt.setConcept(convertCodeableConcept(src)); - return tgt; - } + protected static void copyElement(org.hl7.fhir.r4.model.Element src, org.hl7.fhir.r5.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + protected static void copyElement(org.hl7.fhir.r5.model.Element src, org.hl7.fhir.r4.model.Element tgt, String... extensionsToIgnore) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { + if (!isExemptExtension(e.getUrl(), extensionsToIgnore)) { + tgt.addExtension(convertExtension(e)); + } + } + } + + protected static void copyEnumeration(org.hl7.fhir.r4.model.Enumeration src, org.hl7.fhir.r5.model.Enumeration tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r4.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + protected static void copyEnumeration(org.hl7.fhir.r5.model.Enumeration src, org.hl7.fhir.r4.model.Enumeration tgt) throws FHIRException { + if (src.hasId()) tgt.setId(src.getId()); + for (org.hl7.fhir.r5.model.Extension e : src.getExtension()) { + tgt.addExtension(convertExtension(e)); + } + } + + protected static void copyBackboneElement(org.hl7.fhir.r4.model.BackboneElement src, org.hl7.fhir.r5.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + protected static void copyBackboneElement(org.hl7.fhir.r5.model.BackboneElement src, org.hl7.fhir.r4.model.BackboneElement tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + protected static void copyBackboneElement(org.hl7.fhir.r5.model.BackboneType src, org.hl7.fhir.r4.model.BackboneType tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + protected static void copyBackboneElement(org.hl7.fhir.r4.model.BackboneType src, org.hl7.fhir.r5.model.BackboneType tgt) throws FHIRException { + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Extension e : src.getModifierExtension()) { + tgt.addModifierExtension(convertExtension(e)); + } + } + + protected static org.hl7.fhir.utilities.xhtml.XhtmlNode convertXhtml(org.hl7.fhir.utilities.xhtml.XhtmlNode src) throws FHIRException { + return src; + } + + public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException { + org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.BooleanType convertBoolean(org.hl7.fhir.r4.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r5.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.BooleanType(src.getValue()) : new org.hl7.fhir.r5.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.BooleanType convertBoolean(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { + org.hl7.fhir.r4.model.BooleanType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.BooleanType(src.getValue()) : new org.hl7.fhir.r4.model.BooleanType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.CanonicalType convertCanonical(org.hl7.fhir.r4.model.CanonicalType src) throws FHIRException { + org.hl7.fhir.r5.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CanonicalType(src.getValue()) : new org.hl7.fhir.r5.model.CanonicalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.CanonicalType convertCanonical(org.hl7.fhir.r5.model.CanonicalType src) throws FHIRException { + org.hl7.fhir.r4.model.CanonicalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CanonicalType(src.getValue()) : new org.hl7.fhir.r4.model.CanonicalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeType convertCode(org.hl7.fhir.r4.model.CodeType src) throws FHIRException { + org.hl7.fhir.r5.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.CodeType(src.getValue()) : new org.hl7.fhir.r5.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeType convertCode(org.hl7.fhir.r5.model.CodeType src) throws FHIRException { + org.hl7.fhir.r4.model.CodeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.CodeType(src.getValue()) : new org.hl7.fhir.r4.model.CodeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateType convertDate(org.hl7.fhir.r4.model.DateType src) throws FHIRException { + org.hl7.fhir.r5.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateType(src.getValue()) : new org.hl7.fhir.r5.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateType convertDate(org.hl7.fhir.r5.model.DateType src) throws FHIRException { + org.hl7.fhir.r4.model.DateType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateType(src.getValue()) : new org.hl7.fhir.r4.model.DateType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DateTimeType convertDateTime(org.hl7.fhir.r4.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r5.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DateTimeType convertDateTime(org.hl7.fhir.r5.model.DateTimeType src) throws FHIRException { + org.hl7.fhir.r4.model.DateTimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DateTimeType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DateTimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException { + org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IdType convertId(org.hl7.fhir.r4.model.IdType src) throws FHIRException { + org.hl7.fhir.r5.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IdType(src.getValue()) : new org.hl7.fhir.r5.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IdType convertId(org.hl7.fhir.r5.model.IdType src) throws FHIRException { + org.hl7.fhir.r4.model.IdType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IdType(src.getValue()) : new org.hl7.fhir.r4.model.IdType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.InstantType convertInstant(org.hl7.fhir.r4.model.InstantType src) throws FHIRException { + org.hl7.fhir.r5.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.InstantType(src.getValue()) : new org.hl7.fhir.r5.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.InstantType convertInstant(org.hl7.fhir.r5.model.InstantType src) throws FHIRException { + org.hl7.fhir.r4.model.InstantType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.InstantType(src.getValueAsString()) : new org.hl7.fhir.r4.model.InstantType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValueAsString()) : new org.hl7.fhir.r5.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Integer64Type convertUnsignedIntToInteger64(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r5.model.Integer64Type tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Integer64Type(src.getValueAsString()) : new org.hl7.fhir.r5.model.Integer64Type(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UnsignedIntType convertInteger64ToUnsignedInt(org.hl7.fhir.r5.model.Integer64Type src) throws FHIRException { + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValueAsString()) : new org.hl7.fhir.r4.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.IntegerType convertInteger(org.hl7.fhir.r5.model.IntegerType src) throws FHIRException { + org.hl7.fhir.r4.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.IntegerType(src.getValueAsString()) : new org.hl7.fhir.r4.model.IntegerType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertMarkdown(org.hl7.fhir.r4.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.MarkdownType convertMarkdown(org.hl7.fhir.r5.model.MarkdownType src) throws FHIRException { + org.hl7.fhir.r4.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r4.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.OidType convertOid(org.hl7.fhir.r4.model.OidType src) throws FHIRException { + org.hl7.fhir.r5.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.OidType(src.getValue()) : new org.hl7.fhir.r5.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.OidType convertOid(org.hl7.fhir.r5.model.OidType src) throws FHIRException { + org.hl7.fhir.r4.model.OidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.OidType(src.getValue()) : new org.hl7.fhir.r4.model.OidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r4.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r5.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r5.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.PositiveIntType convertPositiveInt(org.hl7.fhir.r5.model.PositiveIntType src) throws FHIRException { + org.hl7.fhir.r4.model.PositiveIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.PositiveIntType(src.getValue()) : new org.hl7.fhir.r4.model.PositiveIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.StringType convertString(org.hl7.fhir.r4.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.StringType(src.getValue()) : new org.hl7.fhir.r5.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.MarkdownType convertStringToMarkdown(org.hl7.fhir.r4.model.StringType src) throws FHIRException { + org.hl7.fhir.r5.model.MarkdownType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.MarkdownType(src.getValue()) : new org.hl7.fhir.r5.model.MarkdownType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.StringType convertString(org.hl7.fhir.r5.model.StringType src) throws FHIRException { + org.hl7.fhir.r4.model.StringType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.StringType(src.getValue()) : new org.hl7.fhir.r4.model.StringType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.TimeType convertTime(org.hl7.fhir.r4.model.TimeType src) throws FHIRException { + org.hl7.fhir.r5.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.TimeType(src.getValue()) : new org.hl7.fhir.r5.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.TimeType convertTime(org.hl7.fhir.r5.model.TimeType src) throws FHIRException { + org.hl7.fhir.r4.model.TimeType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.TimeType(src.getValue()) : new org.hl7.fhir.r4.model.TimeType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r4.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r5.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r5.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UnsignedIntType convertUnsignedInt(org.hl7.fhir.r5.model.UnsignedIntType src) throws FHIRException { + org.hl7.fhir.r4.model.UnsignedIntType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UnsignedIntType(src.getValue()) : new org.hl7.fhir.r4.model.UnsignedIntType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UriType convertUri(org.hl7.fhir.r4.model.UriType src) throws FHIRException { + org.hl7.fhir.r5.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UriType(src.getValue()) : new org.hl7.fhir.r5.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UriType convertUri(org.hl7.fhir.r5.model.UriType src) throws FHIRException { + org.hl7.fhir.r4.model.UriType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UriType(src.getValue()) : new org.hl7.fhir.r4.model.UriType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UrlType convertUrl(org.hl7.fhir.r4.model.UrlType src) throws FHIRException { + org.hl7.fhir.r5.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UrlType(src.getValue()) : new org.hl7.fhir.r5.model.UrlType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UrlType convertUrl(org.hl7.fhir.r5.model.UrlType src) throws FHIRException { + org.hl7.fhir.r4.model.UrlType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UrlType(src.getValue()) : new org.hl7.fhir.r4.model.UrlType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.UuidType convertUuid(org.hl7.fhir.r4.model.UuidType src) throws FHIRException { + org.hl7.fhir.r5.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.UuidType(src.getValue()) : new org.hl7.fhir.r5.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.UuidType convertUuid(org.hl7.fhir.r5.model.UuidType src) throws FHIRException { + org.hl7.fhir.r4.model.UuidType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.UuidType(src.getValue()) : new org.hl7.fhir.r4.model.UuidType(); + copyElement(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Extension convertExtension(org.hl7.fhir.r4.model.Extension src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Extension tgt = new org.hl7.fhir.r5.model.Extension(); + copyElement(src, tgt); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Extension convertExtension(org.hl7.fhir.r5.model.Extension src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); + copyElement(src, tgt); + if (src.hasUrl()) tgt.setUrlElement(convertUri(src.getUrlElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Narrative convertNarrative(org.hl7.fhir.r4.model.Narrative src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Narrative tgt = new org.hl7.fhir.r5.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(convertXhtml(src.getDiv())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Narrative convertNarrative(org.hl7.fhir.r5.model.Narrative src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Narrative tgt = new org.hl7.fhir.r4.model.Narrative(); + copyElement(src, tgt); + if (src.hasStatus()) tgt.setStatusElement(convertNarrativeStatus(src.getStatusElement())); + if (src.hasDiv()) tgt.setDiv(convertXhtml(src.getDiv())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNarrativeStatus(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Narrative.NarrativeStatusEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + } else { + switch (src.getValue()) { + case GENERATED: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.GENERATED); + break; + case EXTENSIONS: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EXTENSIONS); + break; + case ADDITIONAL: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.ADDITIONAL); + break; + case EMPTY: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.EMPTY); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Narrative.NarrativeStatus.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Address tgt = new org.hl7.fhir.r5.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.getLine().add(convertString(t)); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.r5.model.Address src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); + if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.getLine().add(convertString(t)); + if (src.hasCity()) tgt.setCityElement(convertString(src.getCityElement())); + if (src.hasDistrict()) tgt.setDistrictElement(convertString(src.getDistrictElement())); + if (src.hasState()) tgt.setStateElement(convertString(src.getStateElement())); + if (src.hasPostalCode()) tgt.setPostalCodeElement(convertString(src.getPostalCodeElement())); + if (src.hasCountry()) tgt.setCountryElement(convertString(src.getCountryElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.OLD); + break; + case BILLING: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.BILLING); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.OLD); + break; + case BILLING: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.BILLING); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAddressType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Address.AddressTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAddressType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + } else { + switch (src.getValue()) { + case POSTAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.POSTAL); + break; + case PHYSICAL: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.PHYSICAL); + break; + case BOTH: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.BOTH); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Address.AddressType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Age convertAge(org.hl7.fhir.r4.model.Age src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Age tgt = new org.hl7.fhir.r5.model.Age(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Age convertAge(org.hl7.fhir.r5.model.Age src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Age tgt = new org.hl7.fhir.r4.model.Age(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Annotation convertAnnotation(org.hl7.fhir.r4.model.Annotation src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Annotation tgt = new org.hl7.fhir.r5.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setTextElement(convertMarkdown(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Annotation convertAnnotation(org.hl7.fhir.r5.model.Annotation src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Annotation tgt = new org.hl7.fhir.r4.model.Annotation(); + copyElement(src, tgt); + if (src.hasAuthor()) tgt.setAuthor(convertType(src.getAuthor())); + if (src.hasTime()) tgt.setTimeElement(convertDateTime(src.getTimeElement())); + if (src.hasText()) tgt.setTextElement(convertMarkdown(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Attachment convertAttachment(org.hl7.fhir.r4.model.Attachment src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Attachment tgt = new org.hl7.fhir.r5.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrlElement(convertUrl(src.getUrlElement())); + if (src.hasSize()) tgt.setSizeElement(convertUnsignedIntToInteger64(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Attachment convertAttachment(org.hl7.fhir.r5.model.Attachment src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Attachment tgt = new org.hl7.fhir.r4.model.Attachment(); + copyElement(src, tgt); + if (src.hasContentType()) tgt.setContentTypeElement(convertCode(src.getContentTypeElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + if (src.hasUrl()) tgt.setUrlElement(convertUrl(src.getUrlElement())); + if (src.hasSize()) tgt.setSizeElement(convertInteger64ToUnsignedInt(src.getSizeElement())); + if (src.hasHash()) tgt.setHashElement(convertBase64Binary(src.getHashElement())); + if (src.hasTitle()) tgt.setTitleElement(convertString(src.getTitleElement())); + if (src.hasCreation()) tgt.setCreationElement(convertDateTime(src.getCreationElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getCoding()) tgt.addCoding(convertCoding(t)); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Coding convertCoding(org.hl7.fhir.r4.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Coding tgt = new org.hl7.fhir.r5.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Coding convertCoding(org.hl7.fhir.r5.model.Coding src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Coding tgt = new org.hl7.fhir.r4.model.Coding(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasVersion()) tgt.setVersionElement(convertString(src.getVersionElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasUserSelected()) tgt.setUserSelectedElement(convertBoolean(src.getUserSelectedElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ContactDetail convertContactDetail(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.ContactDetail convertContactDetail(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.r4.model.ContactPoint src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ContactPoint tgt = new org.hl7.fhir.r4.model.ContactPoint(); + copyElement(src, tgt); + if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); + if (src.hasRank()) tgt.setRankElement(convertPositiveInt(src.getRankElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointSystem(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.URL); + break; + case SMS: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.SMS); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointSystemEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + } else { + switch (src.getValue()) { + case PHONE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE); + break; + case FAX: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX); + break; + case EMAIL: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL); + break; + case PAGER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER); + break; + case URL: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL); + break; + case SMS: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS); + break; + case OTHER: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContactPointUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContactPointUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ContactPoint.ContactPointUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + } else { + switch (src.getValue()) { + case HOME: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME); + break; + case WORK: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.OLD); + break; + case MOBILE: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Contributor convertContributor(org.hl7.fhir.r4.model.Contributor src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Contributor tgt = new org.hl7.fhir.r5.model.Contributor(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.Contributor convertContributor(org.hl7.fhir.r5.model.Contributor src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Contributor tgt = new org.hl7.fhir.r4.model.Contributor(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) tgt.addContact(convertContactDetail(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertContributorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Contributor.ContributorTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.NULL); + } else { + switch (src.getValue()) { + case AUTHOR: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.AUTHOR); + break; + case EDITOR: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.EDITOR); + break; + case REVIEWER: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.REVIEWER); + break; + case ENDORSER: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.ENDORSER); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Contributor.ContributorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertContributorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Contributor.ContributorTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL); + } else { + switch (src.getValue()) { + case AUTHOR: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.AUTHOR); + break; + case EDITOR: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.EDITOR); + break; + case REVIEWER: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.REVIEWER); + break; + case ENDORSER: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.ENDORSER); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Count convertCount(org.hl7.fhir.r4.model.Count src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Count tgt = new org.hl7.fhir.r5.model.Count(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Count convertCount(org.hl7.fhir.r5.model.Count src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Count tgt = new org.hl7.fhir.r4.model.Count(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement convertDataRequirement(org.hl7.fhir.r4.model.DataRequirement src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement tgt = new org.hl7.fhir.r5.model.DataRequirement(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); + for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); + if (src.hasSubject()) tgt.setSubject(convertType(src.getSubject())); + for (org.hl7.fhir.r4.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t)); + for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) + tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); + for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) + tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); + if (src.hasLimit()) tgt.setLimitElement(convertPositiveInt(src.getLimitElement())); + for (org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent t : src.getSort()) + tgt.addSort(convertDataRequirementSortComponent(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement convertDataRequirement(org.hl7.fhir.r5.model.DataRequirement src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement tgt = new org.hl7.fhir.r4.model.DataRequirement(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(src.getType().toCode()); + for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); + if (src.hasSubject()) tgt.setSubject(convertType(src.getSubject())); + for (org.hl7.fhir.r5.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t)); + for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent t : src.getCodeFilter()) + tgt.addCodeFilter(convertDataRequirementCodeFilterComponent(t)); + for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent t : src.getDateFilter()) + tgt.addDateFilter(convertDataRequirementDateFilterComponent(t)); + if (src.hasLimit()) tgt.setLimitElement(convertPositiveInt(src.getLimitElement())); + for (org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent t : src.getSort()) + tgt.addSort(convertDataRequirementSortComponent(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasSearchParam()) tgt.setSearchParamElement(convertString(src.getSearchParamElement())); + if (src.hasValueSet()) tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasSearchParam()) tgt.setSearchParamElement(convertString(src.getSearchParamElement())); + if (src.hasValueSet()) tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); + for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasSearchParam()) tgt.setSearchParamElement(convertString(src.getSearchParamElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent convertDataRequirementDateFilterComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementDateFilterComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementDateFilterComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasSearchParam()) tgt.setSearchParamElement(convertString(src.getSearchParamElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent convertDataRequirementSortComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasDirection()) tgt.setDirectionElement(convertSortDirection(src.getDirectionElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent convertDataRequirementSortComponent(org.hl7.fhir.r5.model.DataRequirement.DataRequirementSortComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent tgt = new org.hl7.fhir.r4.model.DataRequirement.DataRequirementSortComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasDirection()) tgt.setDirectionElement(convertSortDirection(src.getDirectionElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSortDirection(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.DataRequirement.SortDirectionEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.NULL); + } else { + switch (src.getValue()) { + case ASCENDING: + tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.ASCENDING); + break; + case DESCENDING: + tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.DESCENDING); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.DataRequirement.SortDirection.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSortDirection(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.DataRequirement.SortDirectionEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.NULL); + } else { + switch (src.getValue()) { + case ASCENDING: + tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.ASCENDING); + break; + case DESCENDING: + tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.DESCENDING); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.DataRequirement.SortDirection.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Distance convertDistance(org.hl7.fhir.r4.model.Distance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Distance tgt = new org.hl7.fhir.r5.model.Distance(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Distance convertDistance(org.hl7.fhir.r5.model.Distance src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Distance tgt = new org.hl7.fhir.r4.model.Distance(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Dosage convertDosage(org.hl7.fhir.r4.model.Dosage src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Dosage tgt = new org.hl7.fhir.r5.model.Dosage(); + copyBackboneElement(src, tgt); + if (src.hasSequence()) tgt.setSequenceElement(convertInteger(src.getSequenceElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAdditionalInstruction()) + tgt.addAdditionalInstruction(convertCodeableConcept(t)); + if (src.hasPatientInstruction()) + tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertCodeableConcept(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + for (org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent t : src.getDoseAndRate()) + tgt.addDoseAndRate(convertDosageDoseAndRateComponent(t)); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasMaxDosePerAdministration()) + tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); + if (src.hasMaxDosePerLifetime()) tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Dosage convertDosage(org.hl7.fhir.r5.model.Dosage src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage(); + copyBackboneElement(src, tgt); + if (src.hasSequence()) tgt.setSequenceElement(convertInteger(src.getSequenceElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + for (org.hl7.fhir.r5.model.CodeableConcept t : src.getAdditionalInstruction()) + tgt.addAdditionalInstruction(convertCodeableConcept(t)); + if (src.hasPatientInstruction()) + tgt.setPatientInstructionElement(convertString(src.getPatientInstructionElement())); + if (src.hasTiming()) tgt.setTiming(convertTiming(src.getTiming())); + if (src.hasAsNeeded()) tgt.setAsNeeded(convertType(src.getAsNeeded())); + if (src.hasSite()) tgt.setSite(convertCodeableConcept(src.getSite())); + if (src.hasRoute()) tgt.setRoute(convertCodeableConcept(src.getRoute())); + if (src.hasMethod()) tgt.setMethod(convertCodeableConcept(src.getMethod())); + for (org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent t : src.getDoseAndRate()) + tgt.addDoseAndRate(convertDosageDoseAndRateComponent(t)); + if (src.hasMaxDosePerPeriod()) tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); + if (src.hasMaxDosePerAdministration()) + tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); + if (src.hasMaxDosePerLifetime()) tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent convertDosageDoseAndRateComponent(org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent tgt = new org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasDose()) tgt.setDose(convertType(src.getDose())); + if (src.hasRate()) tgt.setRate(convertType(src.getRate())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent convertDosageDoseAndRateComponent(org.hl7.fhir.r5.model.Dosage.DosageDoseAndRateComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent tgt = new org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasDose()) tgt.setDose(convertType(src.getDose())); + if (src.hasRate()) tgt.setRate(convertType(src.getRate())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Duration convertDuration(org.hl7.fhir.r4.model.Duration src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Duration tgt = new org.hl7.fhir.r5.model.Duration(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r4.model.Duration convertDuration(org.hl7.fhir.r5.model.Duration src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Duration tgt = new org.hl7.fhir.r4.model.Duration(); + copyQuantity(src, tgt); + return tgt; + } + + public static org.hl7.fhir.r5.model.Expression convertExpression(org.hl7.fhir.r4.model.Expression src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Expression tgt = new org.hl7.fhir.r5.model.Expression(); + copyElement(src, tgt); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasName()) tgt.setNameElement(convertId(src.getNameElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasReference()) tgt.setReferenceElement(convertUri(src.getReferenceElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Expression convertExpression(org.hl7.fhir.r5.model.Expression src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Expression tgt = new org.hl7.fhir.r4.model.Expression(); + copyElement(src, tgt); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasName()) tgt.setNameElement(convertId(src.getNameElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasReference()) tgt.setReferenceElement(convertUri(src.getReferenceElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.HumanName convertHumanName(org.hl7.fhir.r4.model.HumanName src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.HumanName tgt = new org.hl7.fhir.r5.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.setFamilyElement(convertString(src.getFamilyElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.getGiven().add(convertString(t)); + for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.getPrefix().add(convertString(t)); + for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.getSuffix().add(convertString(t)); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + public static org.hl7.fhir.r4.model.HumanName convertHumanName(org.hl7.fhir.r5.model.HumanName src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.HumanName tgt = new org.hl7.fhir.r4.model.HumanName(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); + if (src.hasText()) tgt.setTextElement(convertString(src.getTextElement())); + if (src.hasFamily()) tgt.setFamilyElement(convertString(src.getFamilyElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.getGiven().add(convertString(t)); + for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.getPrefix().add(convertString(t)); + for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.getSuffix().add(convertString(t)); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertNameUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.HumanName.NameUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertNameUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HumanName.NameUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.TEMP); + break; + case NICKNAME: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NICKNAME); + break; + case ANONYMOUS: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.ANONYMOUS); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.OLD); + break; + case MAIDEN: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.MAIDEN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.HumanName.NameUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.r4.model.Identifier src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Identifier tgt = new org.hl7.fhir.r4.model.Identifier(); + copyElement(src, tgt); + if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement())); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasValue()) tgt.setValueElement(convertString(src.getValueElement())); + if (src.hasPeriod()) tgt.setPeriod(convertPeriod(src.getPeriod())); + if (src.hasAssigner()) tgt.setAssigner(convertReference(src.getAssigner())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertIdentifierUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Identifier.IdentifierUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + } else { + switch (src.getValue()) { + case USUAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.USUAL); + break; + case OFFICIAL: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OFFICIAL); + break; + case TEMP: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.TEMP); + break; + case SECONDARY: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.SECONDARY); + break; + case OLD: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.OLD); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Identifier.IdentifierUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.MarketingStatus convertMarketingStatus(org.hl7.fhir.r4.model.MarketingStatus src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.MarketingStatus tgt = new org.hl7.fhir.r5.model.MarketingStatus(); + copyBackboneElement(src, tgt); + if (src.hasCountry()) tgt.setCountry(convertCodeableConcept(src.getCountry())); + if (src.hasJurisdiction()) tgt.setJurisdiction(convertCodeableConcept(src.getJurisdiction())); + if (src.hasStatus()) tgt.setStatus(convertCodeableConcept(src.getStatus())); + if (src.hasDateRange()) tgt.setDateRange(convertPeriod(src.getDateRange())); + if (src.hasRestoreDate()) tgt.setRestoreDateElement(convertDateTime(src.getRestoreDateElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.MarketingStatus convertMarketingStatus(org.hl7.fhir.r5.model.MarketingStatus src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.MarketingStatus tgt = new org.hl7.fhir.r4.model.MarketingStatus(); + copyBackboneElement(src, tgt); + if (src.hasCountry()) tgt.setCountry(convertCodeableConcept(src.getCountry())); + if (src.hasJurisdiction()) tgt.setJurisdiction(convertCodeableConcept(src.getJurisdiction())); + if (src.hasStatus()) tgt.setStatus(convertCodeableConcept(src.getStatus())); + if (src.hasDateRange()) tgt.setDateRange(convertPeriod(src.getDateRange())); + if (src.hasRestoreDate()) tgt.setRestoreDateElement(convertDateTime(src.getRestoreDateElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Meta convertMeta(org.hl7.fhir.r4.model.Meta src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Meta tgt = new org.hl7.fhir.r5.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + if (src.hasSource()) tgt.setSourceElement(convertUri(src.getSourceElement())); + for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); + for (org.hl7.fhir.r4.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r4.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.Meta convertMeta(org.hl7.fhir.r5.model.Meta src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Meta tgt = new org.hl7.fhir.r4.model.Meta(); + copyElement(src, tgt); + if (src.hasVersionId()) tgt.setVersionIdElement(convertId(src.getVersionIdElement())); + if (src.hasLastUpdated()) tgt.setLastUpdatedElement(convertInstant(src.getLastUpdatedElement())); + if (src.hasSource()) tgt.setSourceElement(convertUri(src.getSourceElement())); + for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); + for (org.hl7.fhir.r5.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); + for (org.hl7.fhir.r5.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); + return tgt; + } + + public static org.hl7.fhir.r5.model.Money convertMoney(org.hl7.fhir.r4.model.Money src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Money tgt = new org.hl7.fhir.r5.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrency()) tgt.setCurrencyElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Money convertMoney(org.hl7.fhir.r5.model.Money src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Money tgt = new org.hl7.fhir.r4.model.Money(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasCurrency()) tgt.setCurrencyElement(convertCode(src.getCurrencyElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ParameterDefinition tgt = new org.hl7.fhir.r5.model.ParameterDefinition(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertCode(src.getNameElement())); + if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); + if (src.hasMin()) tgt.setMinElement(convertInteger(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasDocumentation()) tgt.setDocumentationElement(convertString(src.getDocumentationElement())); + if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType())); + if (src.hasProfile()) tgt.setProfileElement(convertCanonical(src.getProfileElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ParameterDefinition convertParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ParameterDefinition tgt = new org.hl7.fhir.r4.model.ParameterDefinition(); + copyElement(src, tgt); + if (src.hasName()) tgt.setNameElement(convertCode(src.getNameElement())); + if (src.hasUse()) tgt.setUseElement(convertParameterUse(src.getUseElement())); + if (src.hasMin()) tgt.setMinElement(convertInteger(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasDocumentation()) tgt.setDocumentationElement(convertString(src.getDocumentationElement())); + if (src.hasType()) tgt.setType(src.getType().toCode()); + if (src.hasProfile()) tgt.setProfileElement(convertCanonical(src.getProfileElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertParameterUse(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.OperationParameterUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); + } else { + switch (src.getValue()) { + case IN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.IN); + break; + case OUT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.OUT); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.OperationParameterUse.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertParameterUse(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ParameterDefinition.ParameterUseEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL); + } else { + switch (src.getValue()) { + case IN: + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.IN); + break; + case OUT: + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.OUT); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ParameterDefinition.ParameterUse.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Period convertPeriod(org.hl7.fhir.r4.model.Period src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Period tgt = new org.hl7.fhir.r5.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Period convertPeriod(org.hl7.fhir.r5.model.Period src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Period tgt = new org.hl7.fhir.r4.model.Period(); + copyElement(src, tgt); + if (src.hasStart()) tgt.setStartElement(convertDateTime(src.getStartElement())); + if (src.hasEnd()) tgt.setEndElement(convertDateTime(src.getEndElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Population convertPopulation(org.hl7.fhir.r4.model.Population src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Population tgt = new org.hl7.fhir.r5.model.Population(); + copyBackboneElement(src, tgt); + if (src.hasAge()) tgt.setAge(convertType(src.getAge())); + if (src.hasGender()) tgt.setGender(convertCodeableConcept(src.getGender())); + if (src.hasRace()) tgt.setRace(convertCodeableConcept(src.getRace())); + if (src.hasPhysiologicalCondition()) + tgt.setPhysiologicalCondition(convertCodeableConcept(src.getPhysiologicalCondition())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Population convertPopulation(org.hl7.fhir.r5.model.Population src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Population tgt = new org.hl7.fhir.r4.model.Population(); + copyBackboneElement(src, tgt); + if (src.hasAge()) tgt.setAge(convertType(src.getAge())); + if (src.hasGender()) tgt.setGender(convertCodeableConcept(src.getGender())); + if (src.hasRace()) tgt.setRace(convertCodeableConcept(src.getRace())); + if (src.hasPhysiologicalCondition()) + tgt.setPhysiologicalCondition(convertCodeableConcept(src.getPhysiologicalCondition())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ProdCharacteristic convertProdCharacteristic(org.hl7.fhir.r4.model.ProdCharacteristic src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ProdCharacteristic tgt = new org.hl7.fhir.r5.model.ProdCharacteristic(); + copyBackboneElement(src, tgt); + if (src.hasHeight()) tgt.setHeight(convertQuantity(src.getHeight())); + if (src.hasWidth()) tgt.setWidth(convertQuantity(src.getWidth())); + if (src.hasDepth()) tgt.setDepth(convertQuantity(src.getDepth())); + if (src.hasWeight()) tgt.setWeight(convertQuantity(src.getWeight())); + if (src.hasNominalVolume()) tgt.setNominalVolume(convertQuantity(src.getNominalVolume())); + if (src.hasExternalDiameter()) tgt.setExternalDiameter(convertQuantity(src.getExternalDiameter())); + if (src.hasShape()) tgt.setShapeElement(convertString(src.getShapeElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getColor()) tgt.getColor().add(convertString(t)); + for (org.hl7.fhir.r4.model.StringType t : src.getImprint()) tgt.getImprint().add(convertString(t)); + for (org.hl7.fhir.r4.model.Attachment t : src.getImage()) tgt.addImage(convertAttachment(t)); + if (src.hasScoring()) tgt.setScoring(convertCodeableConcept(src.getScoring())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ProdCharacteristic convertProdCharacteristic(org.hl7.fhir.r5.model.ProdCharacteristic src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ProdCharacteristic tgt = new org.hl7.fhir.r4.model.ProdCharacteristic(); + copyBackboneElement(src, tgt); + if (src.hasHeight()) tgt.setHeight(convertQuantity(src.getHeight())); + if (src.hasWidth()) tgt.setWidth(convertQuantity(src.getWidth())); + if (src.hasDepth()) tgt.setDepth(convertQuantity(src.getDepth())); + if (src.hasWeight()) tgt.setWeight(convertQuantity(src.getWeight())); + if (src.hasNominalVolume()) tgt.setNominalVolume(convertQuantity(src.getNominalVolume())); + if (src.hasExternalDiameter()) tgt.setExternalDiameter(convertQuantity(src.getExternalDiameter())); + if (src.hasShape()) tgt.setShapeElement(convertString(src.getShapeElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getColor()) tgt.getColor().add(convertString(t)); + for (org.hl7.fhir.r5.model.StringType t : src.getImprint()) tgt.getImprint().add(convertString(t)); + for (org.hl7.fhir.r5.model.Attachment t : src.getImage()) tgt.addImage(convertAttachment(t)); + if (src.hasScoring()) tgt.setScoring(convertCodeableConcept(src.getScoring())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ProductShelfLife convertProductShelfLife(org.hl7.fhir.r4.model.ProductShelfLife src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ProductShelfLife tgt = new org.hl7.fhir.r5.model.ProductShelfLife(); + copyBackboneElement(src, tgt); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasPeriod()) tgt.setPeriod(convertQuantity(src.getPeriod())); + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialPrecautionsForStorage()) + tgt.addSpecialPrecautionsForStorage(convertCodeableConcept(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.ProductShelfLife convertProductShelfLife(org.hl7.fhir.r5.model.ProductShelfLife src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ProductShelfLife tgt = new org.hl7.fhir.r4.model.ProductShelfLife(); + copyBackboneElement(src, tgt); + if (src.hasType()) tgt.setType(convertCodeableConcept(src.getType())); + if (src.hasPeriodQuantity()) tgt.setPeriod(convertQuantity(src.getPeriodQuantity())); + for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialPrecautionsForStorage()) + tgt.addSpecialPrecautionsForStorage(convertCodeableConcept(t)); + return tgt; + } + + public static void copyQuantity(org.hl7.fhir.r4.model.Quantity src, org.hl7.fhir.r5.model.Quantity tgt) throws FHIRException { + if (src == null || tgt == null) return; + copyElement(src, tgt); + if (src.hasValue()) tgt.setValue(src.getValue()); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnit(src.getUnit()); + if (src.hasSystem()) tgt.setSystem(src.getSystem()); + if (src.hasCode()) tgt.setCode(src.getCode()); + } + + public static void copyQuantity(org.hl7.fhir.r5.model.Quantity src, org.hl7.fhir.r4.model.Quantity tgt) throws FHIRException { + if (src == null || tgt == null) return; + copyElement(src, tgt); + if (src.hasValue()) tgt.setValue(src.getValue()); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnit(src.getUnit()); + if (src.hasSystem()) tgt.setSystem(src.getSystem()); + if (src.hasCode()) tgt.setCode(src.getCode()); + } + + public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertQuantityComparator(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Quantity.QuantityComparatorEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + } else { + switch (src.getValue()) { + case LESS_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_THAN); + break; + case LESS_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.LESS_OR_EQUAL); + break; + case GREATER_OR_EQUAL: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_OR_EQUAL); + break; + case GREATER_THAN: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.GREATER_THAN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Quantity.QuantityComparator.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.Range convertRange(org.hl7.fhir.r4.model.Range src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Range tgt = new org.hl7.fhir.r5.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Range convertRange(org.hl7.fhir.r5.model.Range src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Range tgt = new org.hl7.fhir.r4.model.Range(); + copyElement(src, tgt); + if (src.hasLow()) tgt.setLow(convertSimpleQuantity(src.getLow())); + if (src.hasHigh()) tgt.setHigh(convertSimpleQuantity(src.getHigh())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Ratio convertRatio(org.hl7.fhir.r4.model.Ratio src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Ratio tgt = new org.hl7.fhir.r5.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Ratio convertRatio(org.hl7.fhir.r5.model.Ratio src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Ratio tgt = new org.hl7.fhir.r4.model.Ratio(); + copyElement(src, tgt); + if (src.hasNumerator()) tgt.setNumerator(convertQuantity(src.getNumerator())); + if (src.hasDenominator()) tgt.setDenominator(convertQuantity(src.getDenominator())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Reference convertReference(org.hl7.fhir.r4.model.Reference src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Reference tgt = new org.hl7.fhir.r5.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReferenceElement(convertString(src.getReferenceElement_())); + if (src.hasType()) tgt.setTypeElement(convertUri(src.getTypeElement())); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Reference convertReference(org.hl7.fhir.r5.model.Reference src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Reference tgt = new org.hl7.fhir.r4.model.Reference(); + copyElement(src, tgt); + if (src.hasReference()) tgt.setReferenceElement(convertString(src.getReferenceElement_())); + if (src.hasType()) tgt.setTypeElement(convertUri(src.getTypeElement())); + if (src.hasIdentifier()) tgt.setIdentifier(convertIdentifier(src.getIdentifier())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.RelatedArtifact tgt = new org.hl7.fhir.r5.model.RelatedArtifact(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasCitation()) tgt.setCitationElement(convertMarkdown(src.getCitationElement())); + if (src.hasUrl()) tgt.setUrlElement(convertUrl(src.getUrlElement())); + if (src.hasDocument()) tgt.setDocument(convertAttachment(src.getDocument())); + if (src.hasResource()) tgt.setResourceElement(convertCanonical(src.getResourceElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.RelatedArtifact convertRelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.RelatedArtifact tgt = new org.hl7.fhir.r4.model.RelatedArtifact(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertRelatedArtifactType(src.getTypeElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasDisplay()) tgt.setDisplayElement(convertString(src.getDisplayElement())); + if (src.hasCitation()) tgt.setCitationElement(convertMarkdown(src.getCitationElement())); + if (src.hasUrl()) tgt.setUrlElement(convertUrl(src.getUrlElement())); + if (src.hasDocument()) tgt.setDocument(convertAttachment(src.getDocument())); + if (src.hasResource()) tgt.setResourceElement(convertCanonical(src.getResourceElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); + } else { + switch (src.getValue()) { + case DOCUMENTATION: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); + break; + case JUSTIFICATION: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); + break; + case CITATION: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.CITATION); + break; + case PREDECESSOR: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); + break; + case SUCCESSOR: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); + break; + case DERIVEDFROM: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); + break; + case DEPENDSON: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + break; + case COMPOSEDOF: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertRelatedArtifactType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL); + } else { + switch (src.getValue()) { + case DOCUMENTATION: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DOCUMENTATION); + break; + case JUSTIFICATION: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.JUSTIFICATION); + break; + case CITATION: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.CITATION); + break; + case PREDECESSOR: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.PREDECESSOR); + break; + case SUCCESSOR: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.SUCCESSOR); + break; + case DERIVEDFROM: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DERIVEDFROM); + break; + case DEPENDSON: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + break; + case COMPOSEDOF: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.COMPOSEDOF); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.RelatedArtifact.RelatedArtifactType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.SampledData convertSampledData(org.hl7.fhir.r4.model.SampledData src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.SampledData tgt = new org.hl7.fhir.r5.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensions()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasData()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.SampledData convertSampledData(org.hl7.fhir.r5.model.SampledData src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.SampledData tgt = new org.hl7.fhir.r4.model.SampledData(); + copyElement(src, tgt); + if (src.hasOrigin()) tgt.setOrigin(convertSimpleQuantity(src.getOrigin())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasFactor()) tgt.setFactorElement(convertDecimal(src.getFactorElement())); + if (src.hasLowerLimit()) tgt.setLowerLimitElement(convertDecimal(src.getLowerLimitElement())); + if (src.hasUpperLimit()) tgt.setUpperLimitElement(convertDecimal(src.getUpperLimitElement())); + if (src.hasDimensions()) tgt.setDimensionsElement(convertPositiveInt(src.getDimensionsElement())); + if (src.hasData()) tgt.setDataElement(convertString(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Signature convertSignature(org.hl7.fhir.r4.model.Signature src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Signature tgt = new org.hl7.fhir.r5.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhen()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertReference(src.getWho())); + if (src.hasOnBehalfOf()) tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf())); + if (src.hasTargetFormat()) tgt.setTargetFormatElement(convertCode(src.getTargetFormatElement())); + if (src.hasSigFormat()) tgt.setSigFormatElement(convertCode(src.getSigFormatElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Signature convertSignature(org.hl7.fhir.r5.model.Signature src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Signature tgt = new org.hl7.fhir.r4.model.Signature(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t)); + if (src.hasWhen()) tgt.setWhenElement(convertInstant(src.getWhenElement())); + if (src.hasWho()) tgt.setWho(convertReference(src.getWho())); + if (src.hasOnBehalfOf()) tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf())); + if (src.hasTargetFormat()) tgt.setTargetFormatElement(convertCode(src.getTargetFormatElement())); + if (src.hasSigFormat()) tgt.setSigFormatElement(convertCode(src.getSigFormatElement())); + if (src.hasData()) tgt.setDataElement(convertBase64Binary(src.getDataElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.SubstanceAmount convertSubstanceAmount(org.hl7.fhir.r4.model.SubstanceAmount src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.SubstanceAmount tgt = new org.hl7.fhir.r5.model.SubstanceAmount(); + copyBackboneElement(src, tgt); + if (src.hasAmount()) tgt.setAmount(convertType(src.getAmount())); + if (src.hasAmountType()) tgt.setAmountType(convertCodeableConcept(src.getAmountType())); + if (src.hasAmountText()) tgt.setAmountTextElement(convertString(src.getAmountTextElement())); + if (src.hasReferenceRange()) + tgt.setReferenceRange(convertSubstanceAmountReferenceRangeComponent(src.getReferenceRange())); + return tgt; + } + + public static org.hl7.fhir.r4.model.SubstanceAmount convertSubstanceAmount(org.hl7.fhir.r5.model.SubstanceAmount src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.SubstanceAmount tgt = new org.hl7.fhir.r4.model.SubstanceAmount(); + copyBackboneElement(src, tgt); + if (src.hasAmount()) tgt.setAmount(convertType(src.getAmount())); + if (src.hasAmountType()) tgt.setAmountType(convertCodeableConcept(src.getAmountType())); + if (src.hasAmountText()) tgt.setAmountTextElement(convertString(src.getAmountTextElement())); + if (src.hasReferenceRange()) + tgt.setReferenceRange(convertSubstanceAmountReferenceRangeComponent(src.getReferenceRange())); + return tgt; + } + + public static org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent convertSubstanceAmountReferenceRangeComponent(org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent tgt = new org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent(); + copyElement(src, tgt); + if (src.hasLowLimit()) tgt.setLowLimit(convertQuantity(src.getLowLimit())); + if (src.hasHighLimit()) tgt.setHighLimit(convertQuantity(src.getHighLimit())); + return tgt; + } + + public static org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent convertSubstanceAmountReferenceRangeComponent(org.hl7.fhir.r5.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent tgt = new org.hl7.fhir.r4.model.SubstanceAmount.SubstanceAmountReferenceRangeComponent(); + copyElement(src, tgt); + if (src.hasLowLimit()) tgt.setLowLimit(convertQuantity(src.getLowLimit())); + if (src.hasHighLimit()) tgt.setHighLimit(convertQuantity(src.getHighLimit())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.r4.model.Timing src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); + copyBackboneElement(src, tgt); + for (org.hl7.fhir.r4.model.DateTimeType t : src.getEvent()) tgt.getEvent().add(convertDateTime(t)); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Timing tgt = new org.hl7.fhir.r4.model.Timing(); + copyBackboneElement(src, tgt); + for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.getEvent().add(convertDateTime(t)); + if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); + if (src.hasCode()) tgt.setCode(convertCodeableConcept(src.getCode())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCountElement(convertPositiveInt(src.getCountElement())); + if (src.hasCountMax()) tgt.setCountMaxElement(convertPositiveInt(src.getCountMaxElement())); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequencyElement(convertPositiveInt(src.getFrequencyElement())); + if (src.hasFrequencyMax()) tgt.setFrequencyMaxElement(convertPositiveInt(src.getFrequencyMaxElement())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_40_50::convertDayOfWeek).collect(Collectors.toList())); + tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList())); + for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t)); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r4.model.Timing.TimingRepeatComponent(); + copyElement(src, tgt); + if (src.hasBounds()) tgt.setBounds(convertType(src.getBounds())); + if (src.hasCount()) tgt.setCountElement(convertPositiveInt(src.getCountElement())); + if (src.hasCountMax()) tgt.setCountMaxElement(convertPositiveInt(src.getCountMaxElement())); + if (src.hasDuration()) tgt.setDurationElement(convertDecimal(src.getDurationElement())); + if (src.hasDurationMax()) tgt.setDurationMaxElement(convertDecimal(src.getDurationMaxElement())); + if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); + if (src.hasFrequency()) tgt.setFrequencyElement(convertPositiveInt(src.getFrequencyElement())); + if (src.hasFrequencyMax()) tgt.setFrequencyMaxElement(convertPositiveInt(src.getFrequencyMaxElement())); + if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); + if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); + if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); + tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_40_50::convertDayOfWeek).collect(Collectors.toList())); + tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList())); + for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t)); + if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.UnitsOfTimeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + } else { + switch (src.getValue()) { + case S: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.S); + break; + case MIN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MIN); + break; + case H: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.H); + break; + case D: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.D); + break; + case WK: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.WK); + break; + case MO: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.MO); + break; + case A: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.A); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.UnitsOfTime.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertDayOfWeek(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertDayOfWeek(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.DayOfWeekEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL); + } else { + switch (src.getValue()) { + case MON: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.MON); + break; + case TUE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.TUE); + break; + case WED: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.WED); + break; + case THU: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.THU); + break; + case FRI: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.FRI); + break; + case SAT: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SAT); + break; + case SUN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.SUN); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.DayOfWeek.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertEventTiming(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case MORN: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN); + break; + case MORN_EARLY: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN_EARLY); + break; + case MORN_LATE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.MORN_LATE); + break; + case NOON: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NOON); + break; + case AFT: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT); + break; + case AFT_EARLY: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT_EARLY); + break; + case AFT_LATE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AFT_LATE); + break; + case EVE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE); + break; + case EVE_EARLY: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE_EARLY); + break; + case EVE_LATE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.EVE_LATE); + break; + case NIGHT: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NIGHT); + break; + case PHS: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PHS); + break; + case HS: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertEventTiming(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Timing.EventTimingEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + } else { + switch (src.getValue()) { + case MORN: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN); + break; + case MORN_EARLY: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN_EARLY); + break; + case MORN_LATE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.MORN_LATE); + break; + case NOON: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NOON); + break; + case AFT: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT); + break; + case AFT_EARLY: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT_EARLY); + break; + case AFT_LATE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AFT_LATE); + break; + case EVE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE); + break; + case EVE_EARLY: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE_EARLY); + break; + case EVE_LATE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.EVE_LATE); + break; + case NIGHT: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NIGHT); + break; + case PHS: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PHS); + break; + case HS: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.HS); + break; + case WAKE: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.WAKE); + break; + case C: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.C); + break; + case CM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CM); + break; + case CD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CD); + break; + case CV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.CV); + break; + case AC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.AC); + break; + case ACM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACM); + break; + case ACD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACD); + break; + case ACV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.ACV); + break; + case PC: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PC); + break; + case PCM: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCM); + break; + case PCD: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCD); + break; + case PCV: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.PCV); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.Timing.EventTiming.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r4.model.TriggerDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.TriggerDefinition tgt = new org.hl7.fhir.r5.model.TriggerDefinition(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertTriggerType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + if (src.hasTiming()) tgt.setTiming(convertType(src.getTiming())); + for (org.hl7.fhir.r4.model.DataRequirement t : src.getData()) tgt.addData(convertDataRequirement(t)); + if (src.hasCondition()) tgt.setCondition(convertExpression(src.getCondition())); + return tgt; + } + + public static org.hl7.fhir.r4.model.TriggerDefinition convertTriggerDefinition(org.hl7.fhir.r5.model.TriggerDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.TriggerDefinition tgt = new org.hl7.fhir.r4.model.TriggerDefinition(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertTriggerType(src.getTypeElement())); + if (src.hasName()) tgt.setNameElement(convertString(src.getNameElement())); + if (src.hasTiming()) tgt.setTiming(convertType(src.getTiming())); + for (org.hl7.fhir.r5.model.DataRequirement t : src.getData()) tgt.addData(convertDataRequirement(t)); + if (src.hasCondition()) tgt.setCondition(convertExpression(src.getCondition())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertTriggerType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.TriggerDefinition.TriggerTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NULL); + } else { + switch (src.getValue()) { + case NAMEDEVENT: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NAMEDEVENT); + break; + case PERIODIC: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.PERIODIC); + break; + case DATACHANGED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATACHANGED); + break; + case DATAADDED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAADDED); + break; + case DATAMODIFIED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAMODIFIED); + break; + case DATAREMOVED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAREMOVED); + break; + case DATAACCESSED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSED); + break; + case DATAACCESSENDED: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.DATAACCESSENDED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.TriggerDefinition.TriggerType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertTriggerType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.TriggerDefinition.TriggerTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NULL); + } else { + switch (src.getValue()) { + case NAMEDEVENT: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NAMEDEVENT); + break; + case PERIODIC: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.PERIODIC); + break; + case DATACHANGED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATACHANGED); + break; + case DATAADDED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAADDED); + break; + case DATAMODIFIED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAMODIFIED); + break; + case DATAREMOVED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAREMOVED); + break; + case DATAACCESSED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSED); + break; + case DATAACCESSENDED: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.DATAACCESSENDED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.TriggerDefinition.TriggerType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.UsageContext convertUsageContext(org.hl7.fhir.r4.model.UsageContext src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.UsageContext tgt = new org.hl7.fhir.r5.model.UsageContext(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(convertCoding(src.getCode())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.UsageContext convertUsageContext(org.hl7.fhir.r5.model.UsageContext src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.UsageContext tgt = new org.hl7.fhir.r4.model.UsageContext(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCode(convertCoding(src.getCode())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r4.model.ElementDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition(); + copyBackboneElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_40_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setSliceNameElement(convertString(src.getSliceNameElement())); + if (src.hasSliceIsConstraining()) + tgt.setSliceIsConstrainingElement(convertBoolean(src.getSliceIsConstrainingElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.getAlias().add(convertString(t)); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertTypeRefComponent(t)); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) + tgt.addExample(convertElementDefinitionExampleComponent(t)); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r4.model.IdType t : src.getCondition()) tgt.getCondition().add(convertId(t)); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason()) tgt.setIsModifierReasonElement(convertString(src.getIsModifierReasonElement())); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition convertElementDefinition(org.hl7.fhir.r5.model.ElementDefinition src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition tgt = new org.hl7.fhir.r4.model.ElementDefinition(); + copyBackboneElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + tgt.setRepresentation(src.getRepresentation().stream().map(VersionConvertor_40_50::convertPropertyRepresentation).collect(Collectors.toList())); + if (src.hasSliceName()) tgt.setSliceNameElement(convertString(src.getSliceNameElement())); + if (src.hasSliceIsConstraining()) + tgt.setSliceIsConstrainingElement(convertBoolean(src.getSliceIsConstrainingElement())); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t)); + if (src.hasSlicing()) tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing())); + if (src.hasShort()) tgt.setShortElement(convertString(src.getShortElement())); + if (src.hasDefinition()) tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement())); + if (src.hasComment()) tgt.setCommentElement(convertMarkdown(src.getCommentElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement())); + for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.getAlias().add(convertString(t)); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + if (src.hasBase()) tgt.setBase(convertElementDefinitionBaseComponent(src.getBase())); + if (src.hasContentReference()) tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement())); + for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : src.getType()) + tgt.addType(convertTypeRefComponent(t)); + if (src.hasDefaultValue()) tgt.setDefaultValue(convertType(src.getDefaultValue())); + if (src.hasMeaningWhenMissing()) + tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement())); + if (src.hasOrderMeaning()) tgt.setOrderMeaningElement(convertString(src.getOrderMeaningElement())); + if (src.hasFixed()) tgt.setFixed(convertType(src.getFixed())); + if (src.hasPattern()) tgt.setPattern(convertType(src.getPattern())); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent t : src.getExample()) + tgt.addExample(convertElementDefinitionExampleComponent(t)); + if (src.hasMinValue()) tgt.setMinValue(convertType(src.getMinValue())); + if (src.hasMaxValue()) tgt.setMaxValue(convertType(src.getMaxValue())); + if (src.hasMaxLength()) tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement())); + for (org.hl7.fhir.r5.model.IdType t : src.getCondition()) tgt.getCondition().add(convertId(t)); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) + tgt.addConstraint(convertElementDefinitionConstraintComponent(t)); + if (src.hasMustSupport()) tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement())); + if (src.hasIsModifier()) tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement())); + if (src.hasIsModifierReason()) tgt.setIsModifierReasonElement(convertString(src.getIsModifierReasonElement())); + if (src.hasIsSummary()) tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement())); + if (src.hasBinding()) tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding())); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) + tgt.addMapping(convertElementDefinitionMappingComponent(t)); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + case XHTML: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.XHTML); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertPropertyRepresentation(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentationEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + } else { + switch (src.getValue()) { + case XMLATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLATTR); + break; + case XMLTEXT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XMLTEXT); + break; + case TYPEATTR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.TYPEATTR); + break; + case CDATEXT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.CDATEXT); + break; + case XHTML: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.XHTML); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.PropertyRepresentation.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent convertElementDefinitionSlicingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingComponent(); + copyElement(src, tgt); + for (org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t : src.getDiscriminator()) + tgt.addDiscriminator(convertElementDefinitionSlicingDiscriminatorComponent(t)); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasOrdered()) tgt.setOrderedElement(convertBoolean(src.getOrderedElement())); + if (src.hasRules()) tgt.setRulesElement(convertSlicingRules(src.getRulesElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertSlicingRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertSlicingRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.SlicingRulesEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + } else { + switch (src.getValue()) { + case CLOSED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.CLOSED); + break; + case OPEN: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPEN); + break; + case OPENATEND: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.OPENATEND); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.SlicingRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent convertElementDefinitionSlicingDiscriminatorComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent(); + copyElement(src, tgt); + if (src.hasType()) tgt.setTypeElement(convertDiscriminatorType(src.getTypeElement())); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL); + } else { + switch (src.getValue()) { + case VALUE: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.VALUE); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.EXISTS); + break; + case PATTERN: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PATTERN); + break; + case TYPE: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.TYPE); + break; + case PROFILE: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.PROFILE); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.DiscriminatorType.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertDiscriminatorType(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorTypeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL); + } else { + switch (src.getValue()) { + case VALUE: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.VALUE); + break; + case EXISTS: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.EXISTS); + break; + case PATTERN: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PATTERN); + break; + case TYPE: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.TYPE); + break; + case PROFILE: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.PROFILE); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.DiscriminatorType.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent convertElementDefinitionBaseComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBaseComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBaseComponent(); + copyElement(src, tgt); + if (src.hasPath()) tgt.setPathElement(convertString(src.getPathElement())); + if (src.hasMin()) tgt.setMinElement(convertUnsignedInt(src.getMinElement())); + if (src.hasMax()) tgt.setMaxElement(convertString(src.getMaxElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCodeElement(convertUri(src.getCodeElement())); + for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); + for (org.hl7.fhir.r4.model.CanonicalType t : src.getTargetProfile()) + tgt.getTargetProfile().add(convertCanonical(t)); + tgt.setAggregation(src.getAggregation().stream().map(VersionConvertor_40_50::convertAggregationMode).collect(Collectors.toList())); + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent convertTypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent(); + copyElement(src, tgt); + if (src.hasCode()) tgt.setCodeElement(convertUri(src.getCodeElement())); + for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t)); + for (org.hl7.fhir.r5.model.CanonicalType t : src.getTargetProfile()) + tgt.getTargetProfile().add(convertCanonical(t)); + tgt.setAggregation(src.getAggregation().stream().map(VersionConvertor_40_50::convertAggregationMode).collect(Collectors.toList())); + if (src.hasVersioning()) tgt.setVersioningElement(convertReferenceVersionRules(src.getVersioningElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertAggregationMode(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertAggregationMode(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.AggregationModeEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + } else { + switch (src.getValue()) { + case CONTAINED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.CONTAINED); + break; + case REFERENCED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.REFERENCED); + break; + case BUNDLED: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.BUNDLED); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.AggregationMode.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertReferenceVersionRules(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRulesEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); + } else { + switch (src.getValue()) { + case EITHER: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.EITHER); + break; + case INDEPENDENT: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.INDEPENDENT); + break; + case SPECIFIC: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.SPECIFIC); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ReferenceVersionRules.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent convertElementDefinitionExampleComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionExampleComponent(); + copyElement(src, tgt); + if (src.hasLabel()) tgt.setLabelElement(convertString(src.getLabelElement())); + if (src.hasValue()) tgt.setValue(convertType(src.getValue())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKey()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHuman()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpath()) tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasSource()) tgt.setSourceElement(convertCanonical(src.getSourceElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent convertElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionConstraintComponent(); + copyElement(src, tgt); + if (src.hasKey()) tgt.setKeyElement(convertId(src.getKeyElement())); + if (src.hasRequirements()) tgt.setRequirementsElement(convertString(src.getRequirementsElement())); + if (src.hasSeverity()) tgt.setSeverityElement(convertConstraintSeverity(src.getSeverityElement())); + if (src.hasHuman()) tgt.setHumanElement(convertString(src.getHumanElement())); + if (src.hasExpression()) tgt.setExpressionElement(convertString(src.getExpressionElement())); + if (src.hasXpath()) tgt.setXpathElement(convertString(src.getXpathElement())); + if (src.hasSource()) tgt.setSourceElement(convertCanonical(src.getSourceElement())); + return tgt; + } + + static public org.hl7.fhir.r5.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r4.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r5.model.Enumeration tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r5.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + static public org.hl7.fhir.r4.model.Enumeration convertConstraintSeverity(org.hl7.fhir.r5.model.Enumeration src) throws FHIRException { + if (src == null || src.isEmpty()) return null; + org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverityEnumFactory()); + VersionConvertor_40_50.copyElement(src, tgt); + if (src.getValue() == null) { + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + } else { + switch (src.getValue()) { + case ERROR: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.ERROR); + break; + case WARNING: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.WARNING); + break; + default: + tgt.setValue(org.hl7.fhir.r4.model.ElementDefinition.ConstraintSeverity.NULL); + break; + } + } + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(Enumerations40_50.convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent convertElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent(); + copyElement(src, tgt); + if (src.hasStrength()) tgt.setStrengthElement(Enumerations40_50.convertBindingStrength(src.getStrengthElement())); + if (src.hasDescription()) tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + if (src.hasValueSet()) tgt.setValueSetElement(convertCanonical(src.getValueSetElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentity()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMap()) tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasComment()) tgt.setCommentElement(convertString(src.getCommentElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent convertElementDefinitionMappingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent(); + copyElement(src, tgt); + if (src.hasIdentity()) tgt.setIdentityElement(convertId(src.getIdentityElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + if (src.hasMap()) tgt.setMapElement(convertString(src.getMapElement())); + if (src.hasComment()) tgt.setCommentElement(convertString(src.getCommentElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertMoneyQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertMoneyQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.Quantity convertSimpleQuantity(org.hl7.fhir.r4.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r4.model.Quantity convertSimpleQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { + if (src == null) return null; + org.hl7.fhir.r4.model.Quantity tgt = new org.hl7.fhir.r4.model.Quantity(); + copyElement(src, tgt); + if (src.hasValue()) tgt.setValueElement(convertDecimal(src.getValueElement())); + if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); + if (src.hasUnit()) tgt.setUnitElement(convertString(src.getUnitElement())); + if (src.hasSystem()) tgt.setSystemElement(convertUri(src.getSystemElement())); + if (src.hasCode()) tgt.setCodeElement(convertCode(src.getCodeElement())); + return tgt; + } + + public static org.hl7.fhir.r5.model.DataType convertType(org.hl7.fhir.r4.model.Type src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r4.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r4.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r4.model.BooleanType) + return convertBoolean((org.hl7.fhir.r4.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r4.model.CanonicalType) + return convertCanonical((org.hl7.fhir.r4.model.CanonicalType) src); + if (src instanceof org.hl7.fhir.r4.model.CodeType) return convertCode((org.hl7.fhir.r4.model.CodeType) src); + if (src instanceof org.hl7.fhir.r4.model.DateType) return convertDate((org.hl7.fhir.r4.model.DateType) src); + if (src instanceof org.hl7.fhir.r4.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r4.model.DecimalType) + return convertDecimal((org.hl7.fhir.r4.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r4.model.IdType) return convertId((org.hl7.fhir.r4.model.IdType) src); + if (src instanceof org.hl7.fhir.r4.model.InstantType) + return convertInstant((org.hl7.fhir.r4.model.InstantType) src); + if (src instanceof org.hl7.fhir.r4.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r4.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r4.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r4.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r4.model.IntegerType) + return convertInteger((org.hl7.fhir.r4.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r4.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r4.model.OidType) return convertOid((org.hl7.fhir.r4.model.OidType) src); + if (src instanceof org.hl7.fhir.r4.model.StringType) return convertString((org.hl7.fhir.r4.model.StringType) src); + if (src instanceof org.hl7.fhir.r4.model.TimeType) return convertTime((org.hl7.fhir.r4.model.TimeType) src); + if (src instanceof org.hl7.fhir.r4.model.UrlType) return convertUrl((org.hl7.fhir.r4.model.UrlType) src); + if (src instanceof org.hl7.fhir.r4.model.UuidType) return convertUuid((org.hl7.fhir.r4.model.UuidType) src); + if (src instanceof org.hl7.fhir.r4.model.UriType) return convertUri((org.hl7.fhir.r4.model.UriType) src); + if (src instanceof org.hl7.fhir.r4.model.Extension) return convertExtension((org.hl7.fhir.r4.model.Extension) src); + if (src instanceof org.hl7.fhir.r4.model.Narrative) return convertNarrative((org.hl7.fhir.r4.model.Narrative) src); + if (src instanceof org.hl7.fhir.r4.model.Address) return convertAddress((org.hl7.fhir.r4.model.Address) src); + if (src instanceof org.hl7.fhir.r4.model.Age) return convertAge((org.hl7.fhir.r4.model.Age) src); + if (src instanceof org.hl7.fhir.r4.model.Annotation) + return convertAnnotation((org.hl7.fhir.r4.model.Annotation) src); + if (src instanceof org.hl7.fhir.r4.model.Attachment) + return convertAttachment((org.hl7.fhir.r4.model.Attachment) src); + if (src instanceof org.hl7.fhir.r4.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r4.model.Coding) return convertCoding((org.hl7.fhir.r4.model.Coding) src); + if (src instanceof org.hl7.fhir.r4.model.ContactDetail) + return convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) src); + if (src instanceof org.hl7.fhir.r4.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r4.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r4.model.Contributor) + return convertContributor((org.hl7.fhir.r4.model.Contributor) src); + if (src instanceof org.hl7.fhir.r4.model.Count) return convertCount((org.hl7.fhir.r4.model.Count) src); + if (src instanceof org.hl7.fhir.r4.model.DataRequirement) + return convertDataRequirement((org.hl7.fhir.r4.model.DataRequirement) src); + if (src instanceof org.hl7.fhir.r4.model.Distance) return convertDistance((org.hl7.fhir.r4.model.Distance) src); + if (src instanceof org.hl7.fhir.r4.model.Dosage) return convertDosage((org.hl7.fhir.r4.model.Dosage) src); + if (src instanceof org.hl7.fhir.r4.model.Duration) return convertDuration((org.hl7.fhir.r4.model.Duration) src); + if (src instanceof org.hl7.fhir.r4.model.Expression) + return convertExpression((org.hl7.fhir.r4.model.Expression) src); + if (src instanceof org.hl7.fhir.r4.model.HumanName) return convertHumanName((org.hl7.fhir.r4.model.HumanName) src); + if (src instanceof org.hl7.fhir.r4.model.Identifier) + return convertIdentifier((org.hl7.fhir.r4.model.Identifier) src); + if (src instanceof org.hl7.fhir.r4.model.MarketingStatus) + return convertMarketingStatus((org.hl7.fhir.r4.model.MarketingStatus) src); + if (src instanceof org.hl7.fhir.r4.model.Meta) return convertMeta((org.hl7.fhir.r4.model.Meta) src); + if (src instanceof org.hl7.fhir.r4.model.Money) return convertMoney((org.hl7.fhir.r4.model.Money) src); + if (src instanceof org.hl7.fhir.r4.model.ParameterDefinition) + return convertParameterDefinition((org.hl7.fhir.r4.model.ParameterDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Period) return convertPeriod((org.hl7.fhir.r4.model.Period) src); + if (src instanceof org.hl7.fhir.r4.model.Population) + return convertPopulation((org.hl7.fhir.r4.model.Population) src); + if (src instanceof org.hl7.fhir.r4.model.ProdCharacteristic) + return convertProdCharacteristic((org.hl7.fhir.r4.model.ProdCharacteristic) src); + if (src instanceof org.hl7.fhir.r4.model.ProductShelfLife) + return convertProductShelfLife((org.hl7.fhir.r4.model.ProductShelfLife) src); + if (src instanceof org.hl7.fhir.r4.model.MoneyQuantity) + return convertMoneyQuantity((org.hl7.fhir.r4.model.MoneyQuantity) src); + if (src instanceof org.hl7.fhir.r4.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.r4.model.SimpleQuantity) src); + if (src instanceof org.hl7.fhir.r4.model.Quantity) return convertQuantity((org.hl7.fhir.r4.model.Quantity) src); + if (src instanceof org.hl7.fhir.r4.model.Range) return convertRange((org.hl7.fhir.r4.model.Range) src); + if (src instanceof org.hl7.fhir.r4.model.Ratio) return convertRatio((org.hl7.fhir.r4.model.Ratio) src); + if (src instanceof org.hl7.fhir.r4.model.Reference) return convertReference((org.hl7.fhir.r4.model.Reference) src); + if (src instanceof org.hl7.fhir.r4.model.RelatedArtifact) + return convertRelatedArtifact((org.hl7.fhir.r4.model.RelatedArtifact) src); + if (src instanceof org.hl7.fhir.r4.model.SampledData) + return convertSampledData((org.hl7.fhir.r4.model.SampledData) src); + if (src instanceof org.hl7.fhir.r4.model.Signature) return convertSignature((org.hl7.fhir.r4.model.Signature) src); + if (src instanceof org.hl7.fhir.r4.model.SubstanceAmount) + return convertSubstanceAmount((org.hl7.fhir.r4.model.SubstanceAmount) src); + if (src instanceof org.hl7.fhir.r4.model.Timing) return convertTiming((org.hl7.fhir.r4.model.Timing) src); + if (src instanceof org.hl7.fhir.r4.model.TriggerDefinition) + return convertTriggerDefinition((org.hl7.fhir.r4.model.TriggerDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.UsageContext) + return convertUsageContext((org.hl7.fhir.r4.model.UsageContext) src); + if (src instanceof org.hl7.fhir.r4.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.r4.model.ElementDefinition) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + public static org.hl7.fhir.r4.model.Type convertType(org.hl7.fhir.r5.model.DataType src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r5.model.Base64BinaryType) + return convertBase64Binary((org.hl7.fhir.r5.model.Base64BinaryType) src); + if (src instanceof org.hl7.fhir.r5.model.BooleanType) + return convertBoolean((org.hl7.fhir.r5.model.BooleanType) src); + if (src instanceof org.hl7.fhir.r5.model.CanonicalType) + return convertCanonical((org.hl7.fhir.r5.model.CanonicalType) src); + if (src instanceof org.hl7.fhir.r5.model.CodeType) return convertCode((org.hl7.fhir.r5.model.CodeType) src); + if (src instanceof org.hl7.fhir.r5.model.DateType) return convertDate((org.hl7.fhir.r5.model.DateType) src); + if (src instanceof org.hl7.fhir.r5.model.DateTimeType) + return convertDateTime((org.hl7.fhir.r5.model.DateTimeType) src); + if (src instanceof org.hl7.fhir.r5.model.DecimalType) + return convertDecimal((org.hl7.fhir.r5.model.DecimalType) src); + if (src instanceof org.hl7.fhir.r5.model.IdType) return convertId((org.hl7.fhir.r5.model.IdType) src); + if (src instanceof org.hl7.fhir.r5.model.InstantType) + return convertInstant((org.hl7.fhir.r5.model.InstantType) src); + if (src instanceof org.hl7.fhir.r5.model.MarkdownType) + return convertMarkdown((org.hl7.fhir.r5.model.MarkdownType) src); + if (src instanceof org.hl7.fhir.r5.model.OidType) return convertOid((org.hl7.fhir.r5.model.OidType) src); + if (src instanceof org.hl7.fhir.r5.model.PositiveIntType) + return convertPositiveInt((org.hl7.fhir.r5.model.PositiveIntType) src); + if (src instanceof org.hl7.fhir.r5.model.StringType) return convertString((org.hl7.fhir.r5.model.StringType) src); + if (src instanceof org.hl7.fhir.r5.model.TimeType) return convertTime((org.hl7.fhir.r5.model.TimeType) src); + if (src instanceof org.hl7.fhir.r5.model.UnsignedIntType) + return convertUnsignedInt((org.hl7.fhir.r5.model.UnsignedIntType) src); + if (src instanceof org.hl7.fhir.r5.model.IntegerType) + return convertInteger((org.hl7.fhir.r5.model.IntegerType) src); + if (src instanceof org.hl7.fhir.r5.model.UrlType) return convertUrl((org.hl7.fhir.r5.model.UrlType) src); + if (src instanceof org.hl7.fhir.r5.model.UuidType) return convertUuid((org.hl7.fhir.r5.model.UuidType) src); + if (src instanceof org.hl7.fhir.r5.model.UriType) return convertUri((org.hl7.fhir.r5.model.UriType) src); + if (src instanceof org.hl7.fhir.r5.model.Extension) return convertExtension((org.hl7.fhir.r5.model.Extension) src); + if (src instanceof org.hl7.fhir.r5.model.Narrative) return convertNarrative((org.hl7.fhir.r5.model.Narrative) src); + if (src instanceof org.hl7.fhir.r5.model.Address) return convertAddress((org.hl7.fhir.r5.model.Address) src); + if (src instanceof org.hl7.fhir.r5.model.Age) return convertAge((org.hl7.fhir.r5.model.Age) src); + if (src instanceof org.hl7.fhir.r5.model.Annotation) + return convertAnnotation((org.hl7.fhir.r5.model.Annotation) src); + if (src instanceof org.hl7.fhir.r5.model.Attachment) + return convertAttachment((org.hl7.fhir.r5.model.Attachment) src); + if (src instanceof org.hl7.fhir.r5.model.CodeableConcept) + return convertCodeableConcept((org.hl7.fhir.r5.model.CodeableConcept) src); + if (src instanceof org.hl7.fhir.r5.model.Coding) return convertCoding((org.hl7.fhir.r5.model.Coding) src); + if (src instanceof org.hl7.fhir.r5.model.ContactDetail) + return convertContactDetail((org.hl7.fhir.r5.model.ContactDetail) src); + if (src instanceof org.hl7.fhir.r5.model.ContactPoint) + return convertContactPoint((org.hl7.fhir.r5.model.ContactPoint) src); + if (src instanceof org.hl7.fhir.r5.model.Contributor) + return convertContributor((org.hl7.fhir.r5.model.Contributor) src); + if (src instanceof org.hl7.fhir.r5.model.Count) return convertCount((org.hl7.fhir.r5.model.Count) src); + if (src instanceof org.hl7.fhir.r5.model.DataRequirement) + return convertDataRequirement((org.hl7.fhir.r5.model.DataRequirement) src); + if (src instanceof org.hl7.fhir.r5.model.Distance) return convertDistance((org.hl7.fhir.r5.model.Distance) src); + if (src instanceof org.hl7.fhir.r5.model.Dosage) return convertDosage((org.hl7.fhir.r5.model.Dosage) src); + if (src instanceof org.hl7.fhir.r5.model.Duration) return convertDuration((org.hl7.fhir.r5.model.Duration) src); + if (src instanceof org.hl7.fhir.r5.model.Expression) + return convertExpression((org.hl7.fhir.r5.model.Expression) src); + if (src instanceof org.hl7.fhir.r5.model.HumanName) return convertHumanName((org.hl7.fhir.r5.model.HumanName) src); + if (src instanceof org.hl7.fhir.r5.model.Identifier) + return convertIdentifier((org.hl7.fhir.r5.model.Identifier) src); + if (src instanceof org.hl7.fhir.r5.model.MarketingStatus) + return convertMarketingStatus((org.hl7.fhir.r5.model.MarketingStatus) src); + if (src instanceof org.hl7.fhir.r5.model.Meta) return convertMeta((org.hl7.fhir.r5.model.Meta) src); + if (src instanceof org.hl7.fhir.r5.model.Money) return convertMoney((org.hl7.fhir.r5.model.Money) src); + if (src instanceof org.hl7.fhir.r5.model.ParameterDefinition) + return convertParameterDefinition((org.hl7.fhir.r5.model.ParameterDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Period) return convertPeriod((org.hl7.fhir.r5.model.Period) src); + if (src instanceof org.hl7.fhir.r5.model.Population) + return convertPopulation((org.hl7.fhir.r5.model.Population) src); + if (src instanceof org.hl7.fhir.r5.model.ProdCharacteristic) + return convertProdCharacteristic((org.hl7.fhir.r5.model.ProdCharacteristic) src); + if (src instanceof org.hl7.fhir.r5.model.ProductShelfLife) + return convertProductShelfLife((org.hl7.fhir.r5.model.ProductShelfLife) src); + if (src instanceof org.hl7.fhir.r5.model.MoneyQuantity) + return convertMoneyQuantity((org.hl7.fhir.r5.model.MoneyQuantity) src); + if (src instanceof org.hl7.fhir.r5.model.SimpleQuantity) + return convertSimpleQuantity((org.hl7.fhir.r5.model.SimpleQuantity) src); + if (src instanceof org.hl7.fhir.r5.model.Quantity) return convertQuantity((org.hl7.fhir.r5.model.Quantity) src); + if (src instanceof org.hl7.fhir.r5.model.Range) return convertRange((org.hl7.fhir.r5.model.Range) src); + if (src instanceof org.hl7.fhir.r5.model.Ratio) return convertRatio((org.hl7.fhir.r5.model.Ratio) src); + if (src instanceof org.hl7.fhir.r5.model.Reference) return convertReference((org.hl7.fhir.r5.model.Reference) src); + if (src instanceof org.hl7.fhir.r5.model.RelatedArtifact) + return convertRelatedArtifact((org.hl7.fhir.r5.model.RelatedArtifact) src); + if (src instanceof org.hl7.fhir.r5.model.SampledData) + return convertSampledData((org.hl7.fhir.r5.model.SampledData) src); + if (src instanceof org.hl7.fhir.r5.model.Signature) return convertSignature((org.hl7.fhir.r5.model.Signature) src); + if (src instanceof org.hl7.fhir.r5.model.SubstanceAmount) + return convertSubstanceAmount((org.hl7.fhir.r5.model.SubstanceAmount) src); + if (src instanceof org.hl7.fhir.r5.model.Timing) return convertTiming((org.hl7.fhir.r5.model.Timing) src); + if (src instanceof org.hl7.fhir.r5.model.TriggerDefinition) + return convertTriggerDefinition((org.hl7.fhir.r5.model.TriggerDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.UsageContext) + return convertUsageContext((org.hl7.fhir.r5.model.UsageContext) src); + if (src instanceof org.hl7.fhir.r5.model.ElementDefinition) + return convertElementDefinition((org.hl7.fhir.r5.model.ElementDefinition) src); + throw new FHIRException("Unknown type " + src.fhirType()); + } + + protected static void copyDomainResource(org.hl7.fhir.r4.model.DomainResource src, org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r4.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r4.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); + } + + protected static void copyDomainResource(org.hl7.fhir.r5.model.DomainResource src, org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { + copyResource(src, tgt); + if (src.hasText()) tgt.setText(convertNarrative(src.getText())); + for (org.hl7.fhir.r5.model.Resource t : src.getContained()) tgt.addContained(convertResource(t)); + for (org.hl7.fhir.r5.model.Extension t : src.getExtension()) tgt.addExtension(convertExtension(t)); + for (org.hl7.fhir.r5.model.Extension t : src.getModifierExtension()) tgt.addModifierExtension(convertExtension(t)); + } + + protected static void copyResource(org.hl7.fhir.r4.model.Resource src, org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setIdElement(convertId(src.getIdElement())); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRulesElement(convertUri(src.getImplicitRulesElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + } + + protected static void copyResource(org.hl7.fhir.r5.model.Resource src, org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { + if (src.hasId()) tgt.setIdElement(convertId(src.getIdElement())); + if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); + if (src.hasImplicitRules()) tgt.setImplicitRulesElement(convertUri(src.getImplicitRulesElement())); + if (src.hasLanguage()) tgt.setLanguageElement(convertCode(src.getLanguageElement())); + } + + public static org.hl7.fhir.r5.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r4.model.Parameters) + return Parameters40_50.convertParameters((org.hl7.fhir.r4.model.Parameters) src); + if (src instanceof org.hl7.fhir.r4.model.Account) + return Account40_50.convertAccount((org.hl7.fhir.r4.model.Account) src); + if (src instanceof org.hl7.fhir.r4.model.ActivityDefinition) + return ActivityDefinition40_50.convertActivityDefinition((org.hl7.fhir.r4.model.ActivityDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.AllergyIntolerance) + return AllergyIntolerance40_50.convertAllergyIntolerance((org.hl7.fhir.r4.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.r4.model.Appointment) + return Appointment40_50.convertAppointment((org.hl7.fhir.r4.model.Appointment) src); + if (src instanceof org.hl7.fhir.r4.model.AppointmentResponse) + return AppointmentResponse40_50.convertAppointmentResponse((org.hl7.fhir.r4.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.r4.model.AuditEvent) + return AuditEvent40_50.convertAuditEvent((org.hl7.fhir.r4.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.r4.model.Basic) return Basic40_50.convertBasic((org.hl7.fhir.r4.model.Basic) src); + if (src instanceof org.hl7.fhir.r4.model.Binary) + return Binary40_50.convertBinary((org.hl7.fhir.r4.model.Binary) src); + if (src instanceof org.hl7.fhir.r4.model.BiologicallyDerivedProduct) + return BiologicallyDerivedProduct40_50.convertBiologicallyDerivedProduct((org.hl7.fhir.r4.model.BiologicallyDerivedProduct) src); + if (src instanceof org.hl7.fhir.r4.model.BodyStructure) + return BodyStructure40_50.convertBodyStructure((org.hl7.fhir.r4.model.BodyStructure) src); + if (src instanceof org.hl7.fhir.r4.model.Bundle) + return Bundle40_50.convertBundle((org.hl7.fhir.r4.model.Bundle) src); + if (src instanceof org.hl7.fhir.r4.model.CapabilityStatement) + return CapabilityStatement40_50.convertCapabilityStatement((org.hl7.fhir.r4.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r4.model.CarePlan) + return CarePlan40_50.convertCarePlan((org.hl7.fhir.r4.model.CarePlan) src); + if (src instanceof org.hl7.fhir.r4.model.CareTeam) + return CareTeam40_50.convertCareTeam((org.hl7.fhir.r4.model.CareTeam) src); + if (src instanceof org.hl7.fhir.r4.model.ChargeItem) + return ChargeItem40_50.convertChargeItem((org.hl7.fhir.r4.model.ChargeItem) src); + if (src instanceof org.hl7.fhir.r4.model.ChargeItemDefinition) + return ChargeItemDefinition40_50.convertChargeItemDefinition((org.hl7.fhir.r4.model.ChargeItemDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Claim) return Claim40_50.convertClaim((org.hl7.fhir.r4.model.Claim) src); + if (src instanceof org.hl7.fhir.r4.model.ClaimResponse) + return ClaimResponse40_50.convertClaimResponse((org.hl7.fhir.r4.model.ClaimResponse) src); + if (src instanceof org.hl7.fhir.r4.model.ClinicalImpression) + return ClinicalImpression40_50.convertClinicalImpression((org.hl7.fhir.r4.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.r4.model.CodeSystem) + return CodeSystem40_50.convertCodeSystem((org.hl7.fhir.r4.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.r4.model.Communication) + return Communication40_50.convertCommunication((org.hl7.fhir.r4.model.Communication) src); + if (src instanceof org.hl7.fhir.r4.model.CommunicationRequest) + return CommunicationRequest40_50.convertCommunicationRequest((org.hl7.fhir.r4.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.r4.model.CompartmentDefinition) + return CompartmentDefinition40_50.convertCompartmentDefinition((org.hl7.fhir.r4.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Composition) + return Composition40_50.convertComposition((org.hl7.fhir.r4.model.Composition) src); + if (src instanceof org.hl7.fhir.r4.model.ConceptMap) + return ConceptMap40_50.convertConceptMap((org.hl7.fhir.r4.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r4.model.Condition) + return Condition40_50.convertCondition((org.hl7.fhir.r4.model.Condition) src); + if (src instanceof org.hl7.fhir.r4.model.Consent) + return Consent40_50.convertConsent((org.hl7.fhir.r4.model.Consent) src); + if (src instanceof org.hl7.fhir.r4.model.Contract) + return Contract40_50.convertContract((org.hl7.fhir.r4.model.Contract) src); + if (src instanceof org.hl7.fhir.r4.model.Coverage) + return Coverage40_50.convertCoverage((org.hl7.fhir.r4.model.Coverage) src); + if (src instanceof org.hl7.fhir.r4.model.CoverageEligibilityRequest) + return CoverageEligibilityRequest40_50.convertCoverageEligibilityRequest((org.hl7.fhir.r4.model.CoverageEligibilityRequest) src); + if (src instanceof org.hl7.fhir.r4.model.CoverageEligibilityResponse) + return CoverageEligibilityResponse40_50.convertCoverageEligibilityResponse((org.hl7.fhir.r4.model.CoverageEligibilityResponse) src); + if (src instanceof org.hl7.fhir.r4.model.DetectedIssue) + return DetectedIssue40_50.convertDetectedIssue((org.hl7.fhir.r4.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.r4.model.Device) + return Device40_50.convertDevice((org.hl7.fhir.r4.model.Device) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceDefinition) + return DeviceDefinition40_50.convertDeviceDefinition((org.hl7.fhir.r4.model.DeviceDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceMetric) + return DeviceMetric40_50.convertDeviceMetric((org.hl7.fhir.r4.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceRequest) + return DeviceRequest40_50.convertDeviceRequest((org.hl7.fhir.r4.model.DeviceRequest) src); + if (src instanceof org.hl7.fhir.r4.model.DeviceUseStatement) + return DeviceUseStatement40_50.convertDeviceUseStatement((org.hl7.fhir.r4.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.r4.model.DiagnosticReport) + return DiagnosticReport40_50.convertDiagnosticReport((org.hl7.fhir.r4.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.r4.model.DocumentManifest) + return DocumentManifest40_50.convertDocumentManifest((org.hl7.fhir.r4.model.DocumentManifest) src); + if (src instanceof org.hl7.fhir.r4.model.DocumentReference) + return DocumentReference40_50.convertDocumentReference((org.hl7.fhir.r4.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r4.model.Encounter) + return Encounter40_50.convertEncounter((org.hl7.fhir.r4.model.Encounter) src); + if (src instanceof org.hl7.fhir.r4.model.Endpoint) + return Endpoint40_50.convertEndpoint((org.hl7.fhir.r4.model.Endpoint) src); + if (src instanceof org.hl7.fhir.r4.model.EnrollmentRequest) + return EnrollmentRequest40_50.convertEnrollmentRequest((org.hl7.fhir.r4.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.r4.model.EnrollmentResponse) + return EnrollmentResponse40_50.convertEnrollmentResponse((org.hl7.fhir.r4.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.r4.model.EpisodeOfCare) + return EpisodeOfCare40_50.convertEpisodeOfCare((org.hl7.fhir.r4.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.r4.model.EventDefinition) + return EventDefinition40_50.convertEventDefinition((org.hl7.fhir.r4.model.EventDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.ExampleScenario) + return ExampleScenario40_50.convertExampleScenario((org.hl7.fhir.r4.model.ExampleScenario) src); + if (src instanceof org.hl7.fhir.r4.model.ExplanationOfBenefit) + return ExplanationOfBenefit40_50.convertExplanationOfBenefit((org.hl7.fhir.r4.model.ExplanationOfBenefit) src); + if (src instanceof org.hl7.fhir.r4.model.FamilyMemberHistory) + return FamilyMemberHistory40_50.convertFamilyMemberHistory((org.hl7.fhir.r4.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.r4.model.Flag) return Flag40_50.convertFlag((org.hl7.fhir.r4.model.Flag) src); + if (src instanceof org.hl7.fhir.r4.model.Goal) return Goal40_50.convertGoal((org.hl7.fhir.r4.model.Goal) src); + if (src instanceof org.hl7.fhir.r4.model.GraphDefinition) + return GraphDefinition40_50.convertGraphDefinition((org.hl7.fhir.r4.model.GraphDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Group) return Group40_50.convertGroup((org.hl7.fhir.r4.model.Group) src); + if (src instanceof org.hl7.fhir.r4.model.GuidanceResponse) + return GuidanceResponse40_50.convertGuidanceResponse((org.hl7.fhir.r4.model.GuidanceResponse) src); + if (src instanceof org.hl7.fhir.r4.model.HealthcareService) + return HealthcareService40_50.convertHealthcareService((org.hl7.fhir.r4.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.r4.model.ImagingStudy) + return ImagingStudy40_50.convertImagingStudy((org.hl7.fhir.r4.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.r4.model.Immunization) + return Immunization40_50.convertImmunization((org.hl7.fhir.r4.model.Immunization) src); + if (src instanceof org.hl7.fhir.r4.model.ImmunizationEvaluation) + return ImmunizationEvaluation40_50.convertImmunizationEvaluation((org.hl7.fhir.r4.model.ImmunizationEvaluation) src); + if (src instanceof org.hl7.fhir.r4.model.ImmunizationRecommendation) + return ImmunizationRecommendation40_50.convertImmunizationRecommendation((org.hl7.fhir.r4.model.ImmunizationRecommendation) src); + if (src instanceof org.hl7.fhir.r4.model.ImplementationGuide) + return ImplementationGuide40_50.convertImplementationGuide((org.hl7.fhir.r4.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r4.model.InsurancePlan) + return InsurancePlan40_50.convertInsurancePlan((org.hl7.fhir.r4.model.InsurancePlan) src); + if (src instanceof org.hl7.fhir.r4.model.Invoice) + return Invoice40_50.convertInvoice((org.hl7.fhir.r4.model.Invoice) src); + if (src instanceof org.hl7.fhir.r4.model.Library) + return Library40_50.convertLibrary((org.hl7.fhir.r4.model.Library) src); + if (src instanceof org.hl7.fhir.r4.model.Linkage) + return Linkage40_50.convertLinkage((org.hl7.fhir.r4.model.Linkage) src); + if (src instanceof org.hl7.fhir.r4.model.ListResource) + return ListResource40_50.convertListResource((org.hl7.fhir.r4.model.ListResource) src); + if (src instanceof org.hl7.fhir.r4.model.Location) + return Location40_50.convertLocation((org.hl7.fhir.r4.model.Location) src); + if (src instanceof org.hl7.fhir.r4.model.Measure) + return Measure40_50.convertMeasure((org.hl7.fhir.r4.model.Measure) src); + if (src instanceof org.hl7.fhir.r4.model.MeasureReport) + return MeasureReport40_50.convertMeasureReport((org.hl7.fhir.r4.model.MeasureReport) src); + if (src instanceof org.hl7.fhir.r4.model.Media) return Media40_50.convertMedia((org.hl7.fhir.r4.model.Media) src); + if (src instanceof org.hl7.fhir.r4.model.Medication) + return Medication40_50.convertMedication((org.hl7.fhir.r4.model.Medication) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationAdministration) + return MedicationAdministration40_50.convertMedicationAdministration((org.hl7.fhir.r4.model.MedicationAdministration) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationDispense) + return MedicationDispense40_50.convertMedicationDispense((org.hl7.fhir.r4.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationKnowledge) + return MedicationKnowledge40_50.convertMedicationKnowledge((org.hl7.fhir.r4.model.MedicationKnowledge) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationRequest) + return MedicationRequest40_50.convertMedicationRequest((org.hl7.fhir.r4.model.MedicationRequest) src); + if (src instanceof org.hl7.fhir.r4.model.MedicationStatement) + return MedicationStatement40_50.convertMedicationStatement((org.hl7.fhir.r4.model.MedicationStatement) src); + if (src instanceof org.hl7.fhir.r4.model.MedicinalProduct) + return MedicinalProductDefinition40_50.convertMedicinalProduct((org.hl7.fhir.r4.model.MedicinalProduct) src); + if (src instanceof org.hl7.fhir.r4.model.MessageDefinition) + return MessageDefinition40_50.convertMessageDefinition((org.hl7.fhir.r4.model.MessageDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.MessageHeader) + return MessageHeader40_50.convertMessageHeader((org.hl7.fhir.r4.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.r4.model.MolecularSequence) + return MolecularSequence40_50.convertMolecularSequence((org.hl7.fhir.r4.model.MolecularSequence) src); + if (src instanceof org.hl7.fhir.r4.model.NamingSystem) + return NamingSystem40_50.convertNamingSystem((org.hl7.fhir.r4.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r4.model.NutritionOrder) + return NutritionOrder40_50.convertNutritionOrder((org.hl7.fhir.r4.model.NutritionOrder) src); + if (src instanceof org.hl7.fhir.r4.model.Observation) + return Observation40_50.convertObservation((org.hl7.fhir.r4.model.Observation) src); + if (src instanceof org.hl7.fhir.r4.model.ObservationDefinition) + return ObservationDefinition40_50.convertObservationDefinition((org.hl7.fhir.r4.model.ObservationDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.OperationDefinition) + return OperationDefinition40_50.convertOperationDefinition((org.hl7.fhir.r4.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.OperationOutcome) + return OperationOutcome40_50.convertOperationOutcome((org.hl7.fhir.r4.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r4.model.Organization) + return Organization40_50.convertOrganization((org.hl7.fhir.r4.model.Organization) src); + if (src instanceof org.hl7.fhir.r4.model.OrganizationAffiliation) + return OrganizationAffiliation40_50.convertOrganizationAffiliation((org.hl7.fhir.r4.model.OrganizationAffiliation) src); + if (src instanceof org.hl7.fhir.r4.model.Patient) + return Patient40_50.convertPatient((org.hl7.fhir.r4.model.Patient) src); + if (src instanceof org.hl7.fhir.r4.model.PaymentNotice) + return PaymentNotice40_50.convertPaymentNotice((org.hl7.fhir.r4.model.PaymentNotice) src); + if (src instanceof org.hl7.fhir.r4.model.PaymentReconciliation) + return PaymentReconciliation40_50.convertPaymentReconciliation((org.hl7.fhir.r4.model.PaymentReconciliation) src); + if (src instanceof org.hl7.fhir.r4.model.Person) + return Person40_50.convertPerson((org.hl7.fhir.r4.model.Person) src); + if (src instanceof org.hl7.fhir.r4.model.PlanDefinition) + return PlanDefinition40_50.convertPlanDefinition((org.hl7.fhir.r4.model.PlanDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.Practitioner) + return Practitioner40_50.convertPractitioner((org.hl7.fhir.r4.model.Practitioner) src); + if (src instanceof org.hl7.fhir.r4.model.PractitionerRole) + return PractitionerRole40_50.convertPractitionerRole((org.hl7.fhir.r4.model.PractitionerRole) src); + if (src instanceof org.hl7.fhir.r4.model.Procedure) + return Procedure40_50.convertProcedure((org.hl7.fhir.r4.model.Procedure) src); + if (src instanceof org.hl7.fhir.r4.model.Provenance) + return Provenance40_50.convertProvenance((org.hl7.fhir.r4.model.Provenance) src); + if (src instanceof org.hl7.fhir.r4.model.Questionnaire) + return Questionnaire40_50.convertQuestionnaire((org.hl7.fhir.r4.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r4.model.QuestionnaireResponse) + return QuestionnaireResponse40_50.convertQuestionnaireResponse((org.hl7.fhir.r4.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r4.model.RelatedPerson) + return RelatedPerson40_50.convertRelatedPerson((org.hl7.fhir.r4.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.r4.model.RequestGroup) + return RequestGroup40_50.convertRequestGroup((org.hl7.fhir.r4.model.RequestGroup) src); + if (src instanceof org.hl7.fhir.r4.model.ResearchStudy) + return ResearchStudy40_50.convertResearchStudy((org.hl7.fhir.r4.model.ResearchStudy) src); + if (src instanceof org.hl7.fhir.r4.model.ResearchSubject) + return ResearchSubject40_50.convertResearchSubject((org.hl7.fhir.r4.model.ResearchSubject) src); + if (src instanceof org.hl7.fhir.r4.model.RiskAssessment) + return RiskAssessment40_50.convertRiskAssessment((org.hl7.fhir.r4.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.r4.model.Schedule) + return Schedule40_50.convertSchedule((org.hl7.fhir.r4.model.Schedule) src); + if (src instanceof org.hl7.fhir.r4.model.SearchParameter) + return SearchParameter40_50.convertSearchParameter((org.hl7.fhir.r4.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r4.model.ServiceRequest) + return ServiceRequest40_50.convertServiceRequest((org.hl7.fhir.r4.model.ServiceRequest) src); + if (src instanceof org.hl7.fhir.r4.model.Slot) return Slot40_50.convertSlot((org.hl7.fhir.r4.model.Slot) src); + if (src instanceof org.hl7.fhir.r4.model.Specimen) + return Specimen40_50.convertSpecimen((org.hl7.fhir.r4.model.Specimen) src); + if (src instanceof org.hl7.fhir.r4.model.SpecimenDefinition) + return SpecimenDefinition40_50.convertSpecimenDefinition((org.hl7.fhir.r4.model.SpecimenDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.StructureDefinition) + return StructureDefinition40_50.convertStructureDefinition((org.hl7.fhir.r4.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r4.model.StructureMap) + return StructureMap40_50.convertStructureMap((org.hl7.fhir.r4.model.StructureMap) src); + if (src instanceof org.hl7.fhir.r4.model.Substance) + return Substance40_50.convertSubstance((org.hl7.fhir.r4.model.Substance) src); + if (src instanceof org.hl7.fhir.r4.model.SubstanceNucleicAcid) + return SubstanceNucleicAcid40_50.convertSubstanceNucleicAcid((org.hl7.fhir.r4.model.SubstanceNucleicAcid) src); + if (src instanceof org.hl7.fhir.r4.model.SubstancePolymer) + return SubstancePolymer40_50.convertSubstancePolymer((org.hl7.fhir.r4.model.SubstancePolymer) src); + if (src instanceof org.hl7.fhir.r4.model.SubstanceProtein) + return SubstanceProtein40_50.convertSubstanceProtein((org.hl7.fhir.r4.model.SubstanceProtein) src); + if (src instanceof org.hl7.fhir.r4.model.SubstanceReferenceInformation) + return SubstanceReferenceInformation40_50.convertSubstanceReferenceInformation((org.hl7.fhir.r4.model.SubstanceReferenceInformation) src); + if (src instanceof org.hl7.fhir.r4.model.SubstanceSourceMaterial) + return SubstanceSourceMaterial40_50.convertSubstanceSourceMaterial((org.hl7.fhir.r4.model.SubstanceSourceMaterial) src); + if (src instanceof org.hl7.fhir.r4.model.SupplyDelivery) + return SupplyDelivery40_50.convertSupplyDelivery((org.hl7.fhir.r4.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r4.model.SupplyRequest) + return SupplyRequest40_50.convertSupplyRequest((org.hl7.fhir.r4.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.r4.model.Task) return Task40_50.convertTask((org.hl7.fhir.r4.model.Task) src); + if (src instanceof org.hl7.fhir.r4.model.TerminologyCapabilities) + return TerminologyCapabilities40_50.convertTerminologyCapabilities((org.hl7.fhir.r4.model.TerminologyCapabilities) src); + if (src instanceof org.hl7.fhir.r4.model.TestReport) + return TestReport40_50.convertTestReport((org.hl7.fhir.r4.model.TestReport) src); + if (src instanceof org.hl7.fhir.r4.model.TestScript) + return TestScript40_50.convertTestScript((org.hl7.fhir.r4.model.TestScript) src); + if (src instanceof org.hl7.fhir.r4.model.ValueSet) + return ValueSet40_50.convertValueSet((org.hl7.fhir.r4.model.ValueSet) src); + if (src instanceof org.hl7.fhir.r4.model.VerificationResult) + return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r4.model.VerificationResult) src); + if (src instanceof org.hl7.fhir.r4.model.VisionPrescription) + return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r4.model.VisionPrescription) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + public static org.hl7.fhir.r4.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException { + if (src == null) return null; + if (src instanceof org.hl7.fhir.r5.model.Parameters) + return Parameters40_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src); + if (src instanceof org.hl7.fhir.r5.model.Account) + return Account40_50.convertAccount((org.hl7.fhir.r5.model.Account) src); + if (src instanceof org.hl7.fhir.r5.model.ActivityDefinition) + return ActivityDefinition40_50.convertActivityDefinition((org.hl7.fhir.r5.model.ActivityDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.AllergyIntolerance) + return AllergyIntolerance40_50.convertAllergyIntolerance((org.hl7.fhir.r5.model.AllergyIntolerance) src); + if (src instanceof org.hl7.fhir.r5.model.Appointment) + return Appointment40_50.convertAppointment((org.hl7.fhir.r5.model.Appointment) src); + if (src instanceof org.hl7.fhir.r5.model.AppointmentResponse) + return AppointmentResponse40_50.convertAppointmentResponse((org.hl7.fhir.r5.model.AppointmentResponse) src); + if (src instanceof org.hl7.fhir.r5.model.AuditEvent) + return AuditEvent40_50.convertAuditEvent((org.hl7.fhir.r5.model.AuditEvent) src); + if (src instanceof org.hl7.fhir.r5.model.Basic) return Basic40_50.convertBasic((org.hl7.fhir.r5.model.Basic) src); + if (src instanceof org.hl7.fhir.r5.model.Binary) + return Binary40_50.convertBinary((org.hl7.fhir.r5.model.Binary) src); + if (src instanceof org.hl7.fhir.r5.model.BiologicallyDerivedProduct) + return BiologicallyDerivedProduct40_50.convertBiologicallyDerivedProduct((org.hl7.fhir.r5.model.BiologicallyDerivedProduct) src); + if (src instanceof org.hl7.fhir.r5.model.BodyStructure) + return BodyStructure40_50.convertBodyStructure((org.hl7.fhir.r5.model.BodyStructure) src); + if (src instanceof org.hl7.fhir.r5.model.Bundle) + return Bundle40_50.convertBundle((org.hl7.fhir.r5.model.Bundle) src); + if (src instanceof org.hl7.fhir.r5.model.CapabilityStatement) + return CapabilityStatement40_50.convertCapabilityStatement((org.hl7.fhir.r5.model.CapabilityStatement) src); + if (src instanceof org.hl7.fhir.r5.model.CarePlan) + return CarePlan40_50.convertCarePlan((org.hl7.fhir.r5.model.CarePlan) src); + if (src instanceof org.hl7.fhir.r5.model.CareTeam) + return CareTeam40_50.convertCareTeam((org.hl7.fhir.r5.model.CareTeam) src); + if (src instanceof org.hl7.fhir.r5.model.ChargeItem) + return ChargeItem40_50.convertChargeItem((org.hl7.fhir.r5.model.ChargeItem) src); + if (src instanceof org.hl7.fhir.r5.model.ChargeItemDefinition) + return ChargeItemDefinition40_50.convertChargeItemDefinition((org.hl7.fhir.r5.model.ChargeItemDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Claim) return Claim40_50.convertClaim((org.hl7.fhir.r5.model.Claim) src); + if (src instanceof org.hl7.fhir.r5.model.ClaimResponse) + return ClaimResponse40_50.convertClaimResponse((org.hl7.fhir.r5.model.ClaimResponse) src); + if (src instanceof org.hl7.fhir.r5.model.ClinicalImpression) + return ClinicalImpression40_50.convertClinicalImpression((org.hl7.fhir.r5.model.ClinicalImpression) src); + if (src instanceof org.hl7.fhir.r5.model.CodeSystem) + return CodeSystem40_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) src); + if (src instanceof org.hl7.fhir.r5.model.Communication) + return Communication40_50.convertCommunication((org.hl7.fhir.r5.model.Communication) src); + if (src instanceof org.hl7.fhir.r5.model.CommunicationRequest) + return CommunicationRequest40_50.convertCommunicationRequest((org.hl7.fhir.r5.model.CommunicationRequest) src); + if (src instanceof org.hl7.fhir.r5.model.CompartmentDefinition) + return CompartmentDefinition40_50.convertCompartmentDefinition((org.hl7.fhir.r5.model.CompartmentDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Composition) + return Composition40_50.convertComposition((org.hl7.fhir.r5.model.Composition) src); + if (src instanceof org.hl7.fhir.r5.model.ConceptMap) + return ConceptMap40_50.convertConceptMap((org.hl7.fhir.r5.model.ConceptMap) src); + if (src instanceof org.hl7.fhir.r5.model.Condition) + return Condition40_50.convertCondition((org.hl7.fhir.r5.model.Condition) src); + if (src instanceof org.hl7.fhir.r5.model.Consent) + return Consent40_50.convertConsent((org.hl7.fhir.r5.model.Consent) src); + if (src instanceof org.hl7.fhir.r5.model.Contract) + return Contract40_50.convertContract((org.hl7.fhir.r5.model.Contract) src); + if (src instanceof org.hl7.fhir.r5.model.Coverage) + return Coverage40_50.convertCoverage((org.hl7.fhir.r5.model.Coverage) src); + if (src instanceof org.hl7.fhir.r5.model.CoverageEligibilityRequest) + return CoverageEligibilityRequest40_50.convertCoverageEligibilityRequest((org.hl7.fhir.r5.model.CoverageEligibilityRequest) src); + if (src instanceof org.hl7.fhir.r5.model.CoverageEligibilityResponse) + return CoverageEligibilityResponse40_50.convertCoverageEligibilityResponse((org.hl7.fhir.r5.model.CoverageEligibilityResponse) src); + if (src instanceof org.hl7.fhir.r5.model.DetectedIssue) + return DetectedIssue40_50.convertDetectedIssue((org.hl7.fhir.r5.model.DetectedIssue) src); + if (src instanceof org.hl7.fhir.r5.model.Device) + return Device40_50.convertDevice((org.hl7.fhir.r5.model.Device) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceDefinition) + return DeviceDefinition40_50.convertDeviceDefinition((org.hl7.fhir.r5.model.DeviceDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceMetric) + return DeviceMetric40_50.convertDeviceMetric((org.hl7.fhir.r5.model.DeviceMetric) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceRequest) + return DeviceRequest40_50.convertDeviceRequest((org.hl7.fhir.r5.model.DeviceRequest) src); + if (src instanceof org.hl7.fhir.r5.model.DeviceUseStatement) + return DeviceUseStatement40_50.convertDeviceUseStatement((org.hl7.fhir.r5.model.DeviceUseStatement) src); + if (src instanceof org.hl7.fhir.r5.model.DiagnosticReport) + return DiagnosticReport40_50.convertDiagnosticReport((org.hl7.fhir.r5.model.DiagnosticReport) src); + if (src instanceof org.hl7.fhir.r5.model.DocumentManifest) + return DocumentManifest40_50.convertDocumentManifest((org.hl7.fhir.r5.model.DocumentManifest) src); + if (src instanceof org.hl7.fhir.r5.model.DocumentReference) + return DocumentReference40_50.convertDocumentReference((org.hl7.fhir.r5.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r5.model.Encounter) + return Encounter40_50.convertEncounter((org.hl7.fhir.r5.model.Encounter) src); + if (src instanceof org.hl7.fhir.r5.model.Endpoint) + return Endpoint40_50.convertEndpoint((org.hl7.fhir.r5.model.Endpoint) src); + if (src instanceof org.hl7.fhir.r5.model.EnrollmentRequest) + return EnrollmentRequest40_50.convertEnrollmentRequest((org.hl7.fhir.r5.model.EnrollmentRequest) src); + if (src instanceof org.hl7.fhir.r5.model.EnrollmentResponse) + return EnrollmentResponse40_50.convertEnrollmentResponse((org.hl7.fhir.r5.model.EnrollmentResponse) src); + if (src instanceof org.hl7.fhir.r5.model.EpisodeOfCare) + return EpisodeOfCare40_50.convertEpisodeOfCare((org.hl7.fhir.r5.model.EpisodeOfCare) src); + if (src instanceof org.hl7.fhir.r5.model.EventDefinition) + return EventDefinition40_50.convertEventDefinition((org.hl7.fhir.r5.model.EventDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.ExampleScenario) + return ExampleScenario40_50.convertExampleScenario((org.hl7.fhir.r5.model.ExampleScenario) src); + if (src instanceof org.hl7.fhir.r5.model.ExplanationOfBenefit) + return ExplanationOfBenefit40_50.convertExplanationOfBenefit((org.hl7.fhir.r5.model.ExplanationOfBenefit) src); + if (src instanceof org.hl7.fhir.r5.model.FamilyMemberHistory) + return FamilyMemberHistory40_50.convertFamilyMemberHistory((org.hl7.fhir.r5.model.FamilyMemberHistory) src); + if (src instanceof org.hl7.fhir.r5.model.Flag) return Flag40_50.convertFlag((org.hl7.fhir.r5.model.Flag) src); + if (src instanceof org.hl7.fhir.r5.model.Goal) return Goal40_50.convertGoal((org.hl7.fhir.r5.model.Goal) src); + if (src instanceof org.hl7.fhir.r5.model.GraphDefinition) + return GraphDefinition40_50.convertGraphDefinition((org.hl7.fhir.r5.model.GraphDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Group) return Group40_50.convertGroup((org.hl7.fhir.r5.model.Group) src); + if (src instanceof org.hl7.fhir.r5.model.GuidanceResponse) + return GuidanceResponse40_50.convertGuidanceResponse((org.hl7.fhir.r5.model.GuidanceResponse) src); + if (src instanceof org.hl7.fhir.r5.model.HealthcareService) + return HealthcareService40_50.convertHealthcareService((org.hl7.fhir.r5.model.HealthcareService) src); + if (src instanceof org.hl7.fhir.r5.model.ImagingStudy) + return ImagingStudy40_50.convertImagingStudy((org.hl7.fhir.r5.model.ImagingStudy) src); + if (src instanceof org.hl7.fhir.r5.model.Immunization) + return Immunization40_50.convertImmunization((org.hl7.fhir.r5.model.Immunization) src); + if (src instanceof org.hl7.fhir.r5.model.ImmunizationEvaluation) + return ImmunizationEvaluation40_50.convertImmunizationEvaluation((org.hl7.fhir.r5.model.ImmunizationEvaluation) src); + if (src instanceof org.hl7.fhir.r5.model.ImmunizationRecommendation) + return ImmunizationRecommendation40_50.convertImmunizationRecommendation((org.hl7.fhir.r5.model.ImmunizationRecommendation) src); + if (src instanceof org.hl7.fhir.r5.model.ImplementationGuide) + return ImplementationGuide40_50.convertImplementationGuide((org.hl7.fhir.r5.model.ImplementationGuide) src); + if (src instanceof org.hl7.fhir.r5.model.InsurancePlan) + return InsurancePlan40_50.convertInsurancePlan((org.hl7.fhir.r5.model.InsurancePlan) src); + if (src instanceof org.hl7.fhir.r5.model.Invoice) + return Invoice40_50.convertInvoice((org.hl7.fhir.r5.model.Invoice) src); + if (src instanceof org.hl7.fhir.r5.model.Library) + return Library40_50.convertLibrary((org.hl7.fhir.r5.model.Library) src); + if (src instanceof org.hl7.fhir.r5.model.Linkage) + return Linkage40_50.convertLinkage((org.hl7.fhir.r5.model.Linkage) src); + if (src instanceof org.hl7.fhir.r5.model.ListResource) + return ListResource40_50.convertListResource((org.hl7.fhir.r5.model.ListResource) src); + if (src instanceof org.hl7.fhir.r5.model.Location) + return Location40_50.convertLocation((org.hl7.fhir.r5.model.Location) src); + if (src instanceof org.hl7.fhir.r5.model.Measure) + return Measure40_50.convertMeasure((org.hl7.fhir.r5.model.Measure) src); + if (src instanceof org.hl7.fhir.r5.model.MeasureReport) + return MeasureReport40_50.convertMeasureReport((org.hl7.fhir.r5.model.MeasureReport) src); + if (src instanceof org.hl7.fhir.r5.model.DocumentReference) + return Media40_50.convertMedia((org.hl7.fhir.r5.model.DocumentReference) src); + if (src instanceof org.hl7.fhir.r5.model.Medication) + return Medication40_50.convertMedication((org.hl7.fhir.r5.model.Medication) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationAdministration) + return MedicationAdministration40_50.convertMedicationAdministration((org.hl7.fhir.r5.model.MedicationAdministration) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationDispense) + return MedicationDispense40_50.convertMedicationDispense((org.hl7.fhir.r5.model.MedicationDispense) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationKnowledge) + return MedicationKnowledge40_50.convertMedicationKnowledge((org.hl7.fhir.r5.model.MedicationKnowledge) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationRequest) + return MedicationRequest40_50.convertMedicationRequest((org.hl7.fhir.r5.model.MedicationRequest) src); + if (src instanceof org.hl7.fhir.r5.model.MedicationUsage) + return MedicationStatement40_50.convertMedicationStatement((org.hl7.fhir.r5.model.MedicationUsage) src); + if (src instanceof org.hl7.fhir.r5.model.MedicinalProductDefinition) + return MedicinalProductDefinition40_50.convertMedicinalProductDefinition((org.hl7.fhir.r5.model.MedicinalProductDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.MessageDefinition) + return MessageDefinition40_50.convertMessageDefinition((org.hl7.fhir.r5.model.MessageDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.MessageHeader) + return MessageHeader40_50.convertMessageHeader((org.hl7.fhir.r5.model.MessageHeader) src); + if (src instanceof org.hl7.fhir.r5.model.MolecularSequence) + return MolecularSequence40_50.convertMolecularSequence((org.hl7.fhir.r5.model.MolecularSequence) src); + if (src instanceof org.hl7.fhir.r5.model.NamingSystem) + return NamingSystem40_50.convertNamingSystem((org.hl7.fhir.r5.model.NamingSystem) src); + if (src instanceof org.hl7.fhir.r5.model.NutritionOrder) + return NutritionOrder40_50.convertNutritionOrder((org.hl7.fhir.r5.model.NutritionOrder) src); + if (src instanceof org.hl7.fhir.r5.model.Observation) + return Observation40_50.convertObservation((org.hl7.fhir.r5.model.Observation) src); + if (src instanceof org.hl7.fhir.r5.model.ObservationDefinition) + return ObservationDefinition40_50.convertObservationDefinition((org.hl7.fhir.r5.model.ObservationDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.OperationDefinition) + return OperationDefinition40_50.convertOperationDefinition((org.hl7.fhir.r5.model.OperationDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.OperationOutcome) + return OperationOutcome40_50.convertOperationOutcome((org.hl7.fhir.r5.model.OperationOutcome) src); + if (src instanceof org.hl7.fhir.r5.model.Organization) + return Organization40_50.convertOrganization((org.hl7.fhir.r5.model.Organization) src); + if (src instanceof org.hl7.fhir.r5.model.OrganizationAffiliation) + return OrganizationAffiliation40_50.convertOrganizationAffiliation((org.hl7.fhir.r5.model.OrganizationAffiliation) src); + if (src instanceof org.hl7.fhir.r5.model.Patient) + return Patient40_50.convertPatient((org.hl7.fhir.r5.model.Patient) src); + if (src instanceof org.hl7.fhir.r5.model.PaymentNotice) + return PaymentNotice40_50.convertPaymentNotice((org.hl7.fhir.r5.model.PaymentNotice) src); + if (src instanceof org.hl7.fhir.r5.model.PaymentReconciliation) + return PaymentReconciliation40_50.convertPaymentReconciliation((org.hl7.fhir.r5.model.PaymentReconciliation) src); + if (src instanceof org.hl7.fhir.r5.model.Person) + return Person40_50.convertPerson((org.hl7.fhir.r5.model.Person) src); + if (src instanceof org.hl7.fhir.r5.model.PlanDefinition) + return PlanDefinition40_50.convertPlanDefinition((org.hl7.fhir.r5.model.PlanDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.Practitioner) + return Practitioner40_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); + if (src instanceof org.hl7.fhir.r5.model.PractitionerRole) + return PractitionerRole40_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src); + if (src instanceof org.hl7.fhir.r5.model.Procedure) + return Procedure40_50.convertProcedure((org.hl7.fhir.r5.model.Procedure) src); + if (src instanceof org.hl7.fhir.r5.model.Provenance) + return Provenance40_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src); + if (src instanceof org.hl7.fhir.r5.model.Questionnaire) + return Questionnaire40_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); + if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) + return QuestionnaireResponse40_50.convertQuestionnaireResponse((org.hl7.fhir.r5.model.QuestionnaireResponse) src); + if (src instanceof org.hl7.fhir.r5.model.RelatedPerson) + return RelatedPerson40_50.convertRelatedPerson((org.hl7.fhir.r5.model.RelatedPerson) src); + if (src instanceof org.hl7.fhir.r5.model.RequestGroup) + return RequestGroup40_50.convertRequestGroup((org.hl7.fhir.r5.model.RequestGroup) src); + if (src instanceof org.hl7.fhir.r5.model.ResearchStudy) + return ResearchStudy40_50.convertResearchStudy((org.hl7.fhir.r5.model.ResearchStudy) src); + if (src instanceof org.hl7.fhir.r5.model.ResearchSubject) + return ResearchSubject40_50.convertResearchSubject((org.hl7.fhir.r5.model.ResearchSubject) src); + if (src instanceof org.hl7.fhir.r5.model.RiskAssessment) + return RiskAssessment40_50.convertRiskAssessment((org.hl7.fhir.r5.model.RiskAssessment) src); + if (src instanceof org.hl7.fhir.r5.model.Schedule) + return Schedule40_50.convertSchedule((org.hl7.fhir.r5.model.Schedule) src); + if (src instanceof org.hl7.fhir.r5.model.SearchParameter) + return SearchParameter40_50.convertSearchParameter((org.hl7.fhir.r5.model.SearchParameter) src); + if (src instanceof org.hl7.fhir.r5.model.ServiceRequest) + return ServiceRequest40_50.convertServiceRequest((org.hl7.fhir.r5.model.ServiceRequest) src); + if (src instanceof org.hl7.fhir.r5.model.Slot) return Slot40_50.convertSlot((org.hl7.fhir.r5.model.Slot) src); + if (src instanceof org.hl7.fhir.r5.model.Specimen) + return Specimen40_50.convertSpecimen((org.hl7.fhir.r5.model.Specimen) src); + if (src instanceof org.hl7.fhir.r5.model.SpecimenDefinition) + return SpecimenDefinition40_50.convertSpecimenDefinition((org.hl7.fhir.r5.model.SpecimenDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.StructureDefinition) + return StructureDefinition40_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src); + if (src instanceof org.hl7.fhir.r5.model.StructureMap) + return StructureMap40_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src); + if (src instanceof org.hl7.fhir.r5.model.Substance) + return Substance40_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); + if (src instanceof org.hl7.fhir.r5.model.SubstanceNucleicAcid) + return SubstanceNucleicAcid40_50.convertSubstanceNucleicAcid((org.hl7.fhir.r5.model.SubstanceNucleicAcid) src); + if (src instanceof org.hl7.fhir.r5.model.SubstancePolymer) + return SubstancePolymer40_50.convertSubstancePolymer((org.hl7.fhir.r5.model.SubstancePolymer) src); + if (src instanceof org.hl7.fhir.r5.model.SubstanceProtein) + return SubstanceProtein40_50.convertSubstanceProtein((org.hl7.fhir.r5.model.SubstanceProtein) src); + if (src instanceof org.hl7.fhir.r5.model.SubstanceReferenceInformation) + return SubstanceReferenceInformation40_50.convertSubstanceReferenceInformation((org.hl7.fhir.r5.model.SubstanceReferenceInformation) src); + if (src instanceof org.hl7.fhir.r5.model.SubstanceSourceMaterial) + return SubstanceSourceMaterial40_50.convertSubstanceSourceMaterial((org.hl7.fhir.r5.model.SubstanceSourceMaterial) src); + if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) + return SupplyDelivery40_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r5.model.SupplyRequest) + return SupplyRequest40_50.convertSupplyRequest((org.hl7.fhir.r5.model.SupplyRequest) src); + if (src instanceof org.hl7.fhir.r5.model.Task) return Task40_50.convertTask((org.hl7.fhir.r5.model.Task) src); + if (src instanceof org.hl7.fhir.r5.model.TerminologyCapabilities) + return TerminologyCapabilities40_50.convertTerminologyCapabilities((org.hl7.fhir.r5.model.TerminologyCapabilities) src); + if (src instanceof org.hl7.fhir.r5.model.TestReport) + return TestReport40_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); + if (src instanceof org.hl7.fhir.r5.model.TestScript) + return TestScript40_50.convertTestScript((org.hl7.fhir.r5.model.TestScript) src); + if (src instanceof org.hl7.fhir.r5.model.ValueSet) + return ValueSet40_50.convertValueSet((org.hl7.fhir.r5.model.ValueSet) src); + if (src instanceof org.hl7.fhir.r5.model.VerificationResult) + return VerificationResult40_50.convertVerificationResult((org.hl7.fhir.r5.model.VerificationResult) src); + if (src instanceof org.hl7.fhir.r5.model.VisionPrescription) + return VisionPrescription40_50.convertVisionPrescription((org.hl7.fhir.r5.model.VisionPrescription) src); + throw new FHIRException("Unknown resource " + src.fhirType()); + } + + protected static org.hl7.fhir.r5.model.CodeType convertResourceEnum(org.hl7.fhir.r4.model.CodeType src) { + return convertCode(src); + } + + protected static org.hl7.fhir.r4.model.CodeType convertResourceEnum(org.hl7.fhir.r5.model.CodeType src) { + return convertCode(src); + } + + protected static CodeableReference convertReferenceToCodeableReference(org.hl7.fhir.r4.model.Reference src) { + CodeableReference tgt = new CodeableReference(); + tgt.setReference(convertReference(src)); + return tgt; + } + + protected static CodeableReference convertCodeableConceptToCodeableReference(org.hl7.fhir.r4.model.CodeableConcept src) { + CodeableReference tgt = new CodeableReference(); + tgt.setConcept(convertCodeableConcept(src)); + return tgt; + } } \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AdministrativeGender10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AdministrativeGender10_30Test.java new file mode 100644 index 000000000..756b24425 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/AdministrativeGender10_30Test.java @@ -0,0 +1,27 @@ +package org.hl7.fhir.convertors.conv10_30; + +import org.hl7.fhir.convertors.VersionConvertorAdvisor30; +import org.hl7.fhir.convertors.VersionConvertor_10_30; +import org.hl7.fhir.convertors.loaders.R2ToR3Loader; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.io.IOException; +import java.io.InputStream; +import java.util.stream.Stream; + +public class AdministrativeGender10_30Test { + + @Test + @DisplayName("Test 10_30 extension present, value is not") + public void testMedicationRequestConversion() throws IOException { + InputStream dstu2_input = this.getClass().getResourceAsStream("/administrative_gender_null.json"); + org.hl7.fhir.dstu2.model.Patient dstu2 = (org.hl7.fhir.dstu2.model.Patient) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input); + VersionConvertorAdvisor30 advisor = new R2ToR3Loader(); + org.hl7.fhir.dstu3.model.Resource stu_actual = VersionConvertor_10_30.convertResource(dstu2, advisor); + } +} diff --git a/org.hl7.fhir.convertors/src/test/resources/administrative_gender_null.json b/org.hl7.fhir.convertors/src/test/resources/administrative_gender_null.json new file mode 100644 index 000000000..6b64454a5 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/administrative_gender_null.json @@ -0,0 +1,94 @@ +{ + "resourceType": "Patient", + "id": "12743884", + "meta": { + "versionId": "0", + "lastUpdated": "2020-09-15T06:35:01.000Z" + }, + "text": { + "status": "generated", + "div": "

    Patient

    Name: Dawg, Joel

    DOB: Nov 11, 1991

    Status: Active

    " + }, + "identifier": [ + { + "use": "usual", + "type": { + "coding": [ + { + "system": "http://hl7.org/fhir/v2/0203", + "code": "MR", + "display": "Medical record number", + "userSelected": false + } + ], + "text": "MRN" + }, + "system": "urn:oid:2.16.840.1.113883.6.1000", + "value": "7690", + "_value": { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/rendered-value", + "valueString": "00000007690" + } + ] + }, + "period": { + "start": "2020-09-15T06:35:01.000Z" + } + }, + { + "use": "usual", + "type": { + "text": "Military Id" + }, + "system": "urn:oid:2.16.840.1.113883.3.42.10001.100001.12", + "value": "10050007740", + "_value": { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/rendered-value", + "valueString": "10050007740" + } + ] + }, + "period": { + "start": "2020-09-15T06:35:01.000Z" + } + } + ], + "active": true, + "name": [ + { + "use": "official", + "text": "Dawg, Joel", + "family": [ + "Dawg" + ], + "given": [ + "Joel" + ] + } + ], + "telecom": [ + { + "system": "phone", + "value": "3075557575", + "use": "home" + }, + { + "system": "email", + "value": "amitabhp@mindfiresolutions.com", + "use": "work" + } + ], + "_gender": { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", + "valueCode": "unknown" + } + ] + }, + "birthDate": "1991-11-11" +} From e91145921890f7ab65d543267acd77bdfef25a40 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Tue, 24 Nov 2020 10:15:04 -0500 Subject: [PATCH 3/6] Updated for 5.2.1 --- RELEASE_NOTES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e69de29bb..1b722e12c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -0,0 +1,5 @@ +* Fix for issue 373 +* Fix for issue 381 +* Fix for issue 204 +* Internal tools now use OkHttp library for all resource fetching +* Added testing for network tools From b7d683fe1baf7d47bd74cae5227b138d60af8d8f Mon Sep 17 00:00:00 2001 From: markiantorno Date: Tue, 24 Nov 2020 15:33:30 +0000 Subject: [PATCH 4/6] Release: v5.2.1 * Fix for issue 373 * Fix for issue 381 * Fix for issue 204 * Internal tools now use OkHttp library for all resource fetching * Added testing for network tools ***NO_CI*** --- org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 6cf36d30a..ea48670a1 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index d0359774a..7104b1e2e 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index e7a5eac03..8b2e23a63 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 6b8d6fad0..58161f17e 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 66fb59e6f..17d88a6a2 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index f77ef03fd..bb9540da7 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index ffdc2a2ab..780ced2b6 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index a65a326f3..4a8fae399 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 3e3fee649..c8577d5cd 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 5e5960474..a108015c1 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/pom.xml b/pom.xml index c432bc68e..6bd899f4b 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR. --> org.hl7.fhir.core - 5.2.1-SNAPSHOT + 5.2.1 pom From 7adfefa63565c79aaa508a3a65d5d64778a1cb4c Mon Sep 17 00:00:00 2001 From: markiantorno Date: Tue, 24 Nov 2020 16:05:34 +0000 Subject: [PATCH 5/6] Updating version to: 5.2.2-SNAPSHOT and incrementing test cases dependency. --- RELEASE_NOTES.md | 5 ----- org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- org.hl7.fhir.r5/pom.xml | 2 +- org.hl7.fhir.report/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- pom.xml | 2 +- 12 files changed, 11 insertions(+), 16 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1b722e12c..e69de29bb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +0,0 @@ -* Fix for issue 373 -* Fix for issue 381 -* Fix for issue 204 -* Internal tools now use OkHttp library for all resource fetching -* Added testing for network tools diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index ea48670a1..7b01080cc 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 7104b1e2e..21e1b3108 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 8b2e23a63..024d589ac 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 58161f17e..59f28d448 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 17d88a6a2..f07cfc625 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index bb9540da7..a899fd052 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index 780ced2b6..571092edc 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 4a8fae399..3529c1b3d 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index c8577d5cd..a9122c016 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index a108015c1..599952eae 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 6bd899f4b..81c307c44 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ HAPI FHIR. --> org.hl7.fhir.core - 5.2.1 + 5.2.2-SNAPSHOT pom From bdf3e025d33f500544629f927d6c0d8e125fd249 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Tue, 24 Nov 2020 15:08:44 -0500 Subject: [PATCH 6/6] Issue 383 (#384) * added null hasWhen check for all version conversions * updated release notes * error message updated for clarity --- RELEASE_NOTES.md | 1 + .../convertors/VersionConvertor_10_30.java | 2 +- .../convertors/VersionConvertor_10_40.java | 8 ++----- .../convertors/VersionConvertor_10_50.java | 6 ++--- .../convertors/VersionConvertor_14_30.java | 8 ++----- .../convertors/VersionConvertor_14_40.java | 8 ++----- .../convertors/VersionConvertor_30_40.java | 4 ++-- .../convertors/VersionConvertor_30_50.java | 4 ++-- .../convertors/VersionConvertor_40_50.java | 4 ++-- .../TimingRepeatComponent10_30Test.java | 24 +++++++++++++++++++ 10 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/TimingRepeatComponent10_30Test.java diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e69de29bb..8c8eeef40 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -0,0 +1 @@ +* fix for issue 383 \ No newline at end of file diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java index 0d79d3fde..d169a697b 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_30.java @@ -1678,7 +1678,7 @@ public class VersionConvertor_10_30 { if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index 80516df6c..a4fdcf28d 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -1779,9 +1779,7 @@ public class VersionConvertor_10_40 { if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); - if (src.hasWhen()) { - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - } + if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); return tgt; } @@ -1799,9 +1797,7 @@ public class VersionConvertor_10_40 { if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } + if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java index 42bfbbdde..073707cc9 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_50.java @@ -1796,7 +1796,7 @@ public class VersionConvertor_10_50 { if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement())); - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); + if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); return tgt; } @@ -1814,9 +1814,7 @@ public class VersionConvertor_10_50 { if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } + if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java index cb498e531..fb3a82da9 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_30.java @@ -1889,9 +1889,7 @@ public class VersionConvertor_14_30 { if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - } + if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; } @@ -1911,9 +1909,7 @@ public class VersionConvertor_14_30 { if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } + if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java index e674067e4..beb5c3a26 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_14_40.java @@ -2002,9 +2002,7 @@ public class VersionConvertor_14_40 { if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); - } + if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; } @@ -2024,9 +2022,7 @@ public class VersionConvertor_14_40 { if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement())); if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); - if (src.hasWhen()) { - tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); - } + if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java index 04689a6a7..1e2e01df8 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java @@ -2425,7 +2425,7 @@ public class VersionConvertor_30_40 { if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_40::convertDayOfWeek).collect(Collectors.toList())); for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); - tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList())); + if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList())); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; } @@ -2447,7 +2447,7 @@ public class VersionConvertor_30_40 { if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_40::convertDayOfWeek).collect(Collectors.toList())); for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); - tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList())); + if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList())); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java index a2e062c49..a2462232f 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_50.java @@ -2481,7 +2481,7 @@ public class VersionConvertor_30_50 { if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_50::convertDayOfWeek).collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList())); + if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList())); for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; @@ -2503,7 +2503,7 @@ public class VersionConvertor_30_50 { if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_50::convertDayOfWeek).collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList())); + if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList())); for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java index 700a8eed4..b6b7af5dc 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_40_50.java @@ -2053,7 +2053,7 @@ public class VersionConvertor_40_50 { if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_40_50::convertDayOfWeek).collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList())); + if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList())); for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t)); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; @@ -2075,7 +2075,7 @@ public class VersionConvertor_40_50 { if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement())); if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_40_50::convertDayOfWeek).collect(Collectors.toList())); - tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList())); + if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList())); for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t)); if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement())); return tgt; diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/TimingRepeatComponent10_30Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/TimingRepeatComponent10_30Test.java new file mode 100644 index 000000000..182eb631e --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_30/TimingRepeatComponent10_30Test.java @@ -0,0 +1,24 @@ +package org.hl7.fhir.convertors.conv10_30; + +import org.hl7.fhir.convertors.VersionConvertor_10_30; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class TimingRepeatComponent10_30Test { + + @Test + @DisplayName("Issue #383 - Test 10_30 TimingRepeatComponent with Timing.when as null") + public void testMedicationRequestConversion() { + final int SET_COUNT = 11; + org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent(); + src.setCount(SET_COUNT); + + org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = VersionConvertor_10_30.convertTimingRepeatComponent(src); + + Assertions.assertEquals(SET_COUNT, tgt.getCount(), "Count field not preserved through version conversion."); + Assertions.assertFalse(tgt.hasWhen(), "hasWhen() should return false for this conversion."); + Assertions.assertTrue(tgt.getWhen().isEmpty(), "When no _when time_ is provided, getWhen() should return an empty list."); + } + +}