
001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Code30_50; 009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50; 010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50; 011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 012import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50; 013import org.hl7.fhir.exceptions.FHIRException; 014 015public class CompartmentDefinition30_50 { 016 017 public static org.hl7.fhir.r5.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.dstu3.model.CompartmentDefinition src) throws FHIRException { 018 if (src == null) 019 return null; 020 org.hl7.fhir.r5.model.CompartmentDefinition tgt = new org.hl7.fhir.r5.model.CompartmentDefinition(); 021 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 022 if (src.hasUrl()) 023 tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement())); 024 if (src.hasName()) 025 tgt.setNameElement(String30_50.convertString(src.getNameElement())); 026 if (src.hasTitle()) 027 tgt.setTitleElement(String30_50.convertString(src.getTitleElement())); 028 if (src.hasStatus()) 029 tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement())); 030 if (src.hasExperimental()) 031 tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement())); 032 if (src.hasDate()) 033 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 034 if (src.hasPublisher()) 035 tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement())); 036 for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) 037 tgt.addContact(ContactDetail30_50.convertContactDetail(t)); 038 if (src.hasDescription()) 039 tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement())); 040 if (src.hasPurpose()) 041 tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement())); 042 for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext()) 043 tgt.addUseContext(UsageContext30_50.convertUsageContext(t)); 044 if (src.hasCode()) 045 tgt.setCodeElement(convertCompartmentType(src.getCodeElement())); 046 if (src.hasSearch()) 047 tgt.setSearchElement(Boolean30_50.convertBoolean(src.getSearchElement())); 048 for (org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource()) 049 tgt.addResource(convertCompartmentDefinitionResourceComponent(t)); 050 return tgt; 051 } 052 053 public static org.hl7.fhir.dstu3.model.CompartmentDefinition convertCompartmentDefinition(org.hl7.fhir.r5.model.CompartmentDefinition src) throws FHIRException { 054 if (src == null) 055 return null; 056 org.hl7.fhir.dstu3.model.CompartmentDefinition tgt = new org.hl7.fhir.dstu3.model.CompartmentDefinition(); 057 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 058 if (src.hasUrl()) 059 tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement())); 060 if (src.hasName()) 061 tgt.setNameElement(String30_50.convertString(src.getNameElement())); 062 if (src.hasTitle()) 063 tgt.setTitleElement(String30_50.convertString(src.getTitleElement())); 064 if (src.hasStatus()) 065 tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement())); 066 if (src.hasExperimental()) 067 tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement())); 068 if (src.hasDate()) 069 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 070 if (src.hasPublisher()) 071 tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement())); 072 for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) 073 tgt.addContact(ContactDetail30_50.convertContactDetail(t)); 074 if (src.hasDescription()) 075 tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement())); 076 if (src.hasPurpose()) 077 tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement())); 078 for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) 079 tgt.addUseContext(UsageContext30_50.convertUsageContext(t)); 080 if (src.hasCode()) 081 tgt.setCodeElement(convertCompartmentType(src.getCodeElement())); 082 if (src.hasSearch()) 083 tgt.setSearchElement(Boolean30_50.convertBoolean(src.getSearchElement())); 084 for (org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent t : src.getResource()) 085 tgt.addResource(convertCompartmentDefinitionResourceComponent(t)); 086 return tgt; 087 } 088 089 public static org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException { 090 if (src == null) 091 return null; 092 org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent(); 093 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 094 if (src.hasCode()) 095 tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement())); 096 for (org.hl7.fhir.dstu3.model.StringType t : src.getParam()) tgt.addParam(t.getValue()); 097 if (src.hasDocumentation()) 098 tgt.setDocumentationElement(String30_50.convertString(src.getDocumentationElement())); 099 return tgt; 100 } 101 102 public static org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent convertCompartmentDefinitionResourceComponent(org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent src) throws FHIRException { 103 if (src == null) 104 return null; 105 org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent tgt = new org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentDefinitionResourceComponent(); 106 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 107 if (src.hasCode()) 108 tgt.setCodeElement(Code30_50.convertCode(src.getCodeElement())); 109 for (org.hl7.fhir.r5.model.StringType t : src.getParam()) tgt.addParam(t.getValue()); 110 if (src.hasDocumentation()) 111 tgt.setDocumentationElement(String30_50.convertString(src.getDocumentationElement())); 112 return tgt; 113 } 114 115 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType> convertCompartmentType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> src) throws FHIRException { 116 if (src == null || src.isEmpty()) 117 return null; 118 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentTypeEnumFactory()); 119 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 120 switch (src.getValue()) { 121 case PATIENT: 122 tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.PATIENT); 123 break; 124 case ENCOUNTER: 125 tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.ENCOUNTER); 126 break; 127 case RELATEDPERSON: 128 tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.RELATEDPERSON); 129 break; 130 case PRACTITIONER: 131 tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.PRACTITIONER); 132 break; 133 case DEVICE: 134 tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.DEVICE); 135 break; 136 default: 137 tgt.setValue(org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType.NULL); 138 break; 139 } 140 return tgt; 141 } 142 143 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompartmentType> convertCompartmentType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CompartmentDefinition.CompartmentType> src) throws FHIRException { 144 if (src == null || src.isEmpty()) 145 return null; 146 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()); 147 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 148 switch (src.getValue()) { 149 case PATIENT: 150 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.PATIENT); 151 break; 152 case ENCOUNTER: 153 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.ENCOUNTER); 154 break; 155 case RELATEDPERSON: 156 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.RELATEDPERSON); 157 break; 158 case PRACTITIONER: 159 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.PRACTITIONER); 160 break; 161 case DEVICE: 162 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.DEVICE); 163 break; 164 default: 165 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompartmentType.NULL); 166 break; 167 } 168 return tgt; 169 } 170}