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