001package org.hl7.fhir.convertors.conv43_50.resources43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Code43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50; 010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; 011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50; 012import org.hl7.fhir.exceptions.FHIRException; 013 014/* 015 Copyright (c) 2011+, HL7, Inc. 016 All rights reserved. 017 018 Redistribution and use in source and binary forms, with or without modification, 019 are permitted provided that the following conditions are met: 020 021 * Redistributions of source code must retain the above copyright notice, this 022 list of conditions and the following disclaimer. 023 * Redistributions in binary form must reproduce the above copyright notice, 024 this list of conditions and the following disclaimer in the documentation 025 and/or other materials provided with the distribution. 026 * Neither the name of HL7 nor the names of its contributors may be used to 027 endorse or promote products derived from this software without specific 028 prior written permission. 029 030 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 031 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 032 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 033 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 034 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 035 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 036 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 037 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 039 POSSIBILITY OF SUCH DAMAGE. 040 041*/ 042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 043public class CompartmentDefinition43_50 { 044 045 public static org.hl7.fhir.r5.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.r4b.model.CompartmentDefinition src) throws FHIRException { 046 if (src == null) 047 return null; 048 org.hl7.fhir.r5.model.CompartmentDefinition tgt = new org.hl7.fhir.r5.model.CompartmentDefinition(); 049 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 050 if (src.hasUrl()) 051 tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement())); 052 if (src.hasVersion()) 053 tgt.setVersionElement(String43_50.convertString(src.getVersionElement())); 054 if (src.hasName()) 055 tgt.setNameElement(String43_50.convertString(src.getNameElement())); 056 if (src.hasStatus()) 057 tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement())); 058 if (src.hasExperimental()) 059 tgt.setExperimentalElement(Boolean43_50.convertBoolean(src.getExperimentalElement())); 060 if (src.hasDate()) 061 tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement())); 062 if (src.hasPublisher()) 063 tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement())); 064 for (org.hl7.fhir.r4b.model.ContactDetail t : src.getContact()) 065 tgt.addContact(ContactDetail43_50.convertContactDetail(t)); 066 if (src.hasDescription()) 067 tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement())); 068 for (org.hl7.fhir.r4b.model.UsageContext t : src.getUseContext()) 069 tgt.addUseContext(UsageContext43_50.convertUsageContext(t)); 070 if (src.hasPurpose()) 071 tgt.setPurposeElement(MarkDown43_50.convertMarkdown(src.getPurposeElement())); 072 if (src.hasCode()) 073 tgt.setCodeElement(convertCompartmentType(src.getCodeElement())); 074 if (src.hasSearch()) 075 tgt.setSearchElement(Boolean43_50.convertBoolean(src.getSearchElement())); 076 for (org.hl7.fhir.r4b.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource()) 077 tgt.addResource(convertCompartmentDefinitionResourceComponent(t)); 078 return tgt; 079 } 080 081 public static org.hl7.fhir.r4b.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.r5.model.CompartmentDefinition src) throws FHIRException { 082 if (src == null) 083 return null; 084 org.hl7.fhir.r4b.model.CompartmentDefinition tgt = new org.hl7.fhir.r4b.model.CompartmentDefinition(); 085 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 086 if (src.hasUrl()) 087 tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement())); 088 if (src.hasVersion()) 089 tgt.setVersionElement(String43_50.convertString(src.getVersionElement())); 090 if (src.hasName()) 091 tgt.setNameElement(String43_50.convertString(src.getNameElement())); 092 if (src.hasStatus()) 093 tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement())); 094 if (src.hasExperimental()) 095 tgt.setExperimentalElement(Boolean43_50.convertBoolean(src.getExperimentalElement())); 096 if (src.hasDate()) 097 tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement())); 098 if (src.hasPublisher()) 099 tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement())); 100 for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) 101 tgt.addContact(ContactDetail43_50.convertContactDetail(t)); 102 if (src.hasDescription()) 103 tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement())); 104 for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) 105 tgt.addUseContext(UsageContext43_50.convertUsageContext(t)); 106 if (src.hasPurpose()) 107 tgt.setPurposeElement(MarkDown43_50.convertMarkdown(src.getPurposeElement())); 108 if (src.hasCode()) 109 tgt.setCodeElement(convertCompartmentType(src.getCodeElement())); 110 if (src.hasSearch()) 111 tgt.setSearchElement(Boolean43_50.convertBoolean(src.getSearchElement())); 112 for (org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource()) 113 tgt.addResource(convertCompartmentDefinitionResourceComponent(t)); 114 return tgt; 115 } 116 117 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> convertCompartmentType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.CompartmentType> src) throws FHIRException { 118 if (src == null || src.isEmpty()) 119 return null; 120 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.CompartmentTypeEnumFactory()); 121 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 122 switch (src.getValue()) { 123 case PATIENT: 124 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.PATIENT); 125 break; 126 case ENCOUNTER: 127 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.ENCOUNTER); 128 break; 129 case RELATEDPERSON: 130 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.RELATEDPERSON); 131 break; 132 case PRACTITIONER: 133 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.PRACTITIONER); 134 break; 135 case DEVICE: 136 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.DEVICE); 137 break; 138 default: 139 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.NULL); 140 break; 141 } 142 return tgt; 143 } 144 145 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.CompartmentType> convertCompartmentType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> src) throws FHIRException { 146 if (src == null || src.isEmpty()) 147 return null; 148 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.CompartmentType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.CompartmentTypeEnumFactory()); 149 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 150 switch (src.getValue()) { 151 case PATIENT: 152 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompartmentType.PATIENT); 153 break; 154 case ENCOUNTER: 155 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompartmentType.ENCOUNTER); 156 break; 157 case RELATEDPERSON: 158 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompartmentType.RELATEDPERSON); 159 break; 160 case PRACTITIONER: 161 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompartmentType.PRACTITIONER); 162 break; 163 case DEVICE: 164 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompartmentType.DEVICE); 165 break; 166 default: 167 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompartmentType.NULL); 168 break; 169 } 170 return tgt; 171 } 172 173 public static org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.r4b.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException { 174 if (src == null) 175 return null; 176 org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent(); 177 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 178 if (src.hasCode()) 179 tgt.setCodeElement(Code43_50.convertCode(src.getCodeElement())); 180 for (org.hl7.fhir.r4b.model.StringType t : src.getParam()) tgt.getParam().add(String43_50.convertString(t)); 181 if (src.hasDocumentation()) 182 tgt.setDocumentationElement(String43_50.convertString(src.getDocumentationElement())); 183 return tgt; 184 } 185 186 public static org.hl7.fhir.r4b.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException { 187 if (src == null) 188 return null; 189 org.hl7.fhir.r4b.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.r4b.model.CompartmentDefinition.CompartmentDefinitionResourceComponent(); 190 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 191 if (src.hasCode()) 192 tgt.setCodeElement(Code43_50.convertCode(src.getCodeElement())); 193 for (org.hl7.fhir.r5.model.StringType t : src.getParam()) tgt.getParam().add(String43_50.convertString(t)); 194 if (src.hasDocumentation()) 195 tgt.setDocumentationElement(String43_50.convertString(src.getDocumentationElement())); 196 return tgt; 197 } 198}