
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.Reference30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Annotation30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_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.String30_50; 011import org.hl7.fhir.dstu3.model.ListResource; 012import org.hl7.fhir.exceptions.FHIRException; 013import org.hl7.fhir.r5.model.Enumeration; 014import org.hl7.fhir.r5.model.Enumerations; 015 016public class List30_50 { 017 018 public static org.hl7.fhir.r5.model.ListResource convertList(org.hl7.fhir.dstu3.model.ListResource src) throws FHIRException { 019 if (src == null) 020 return null; 021 org.hl7.fhir.r5.model.ListResource tgt = new org.hl7.fhir.r5.model.ListResource(); 022 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 023 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 024 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 025 if (src.hasStatus()) 026 tgt.setStatusElement(convertListStatus(src.getStatusElement())); 027 if (src.hasMode()) 028 tgt.setModeElement(convertListMode(src.getModeElement())); 029 if (src.hasTitle()) 030 tgt.setTitleElement(String30_50.convertString(src.getTitleElement())); 031 if (src.hasCode()) 032 tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 033 if (src.hasSubject()) 034 tgt.addSubject(Reference30_50.convertReference(src.getSubject())); 035 if (src.hasEncounter()) 036 tgt.setEncounter(Reference30_50.convertReference(src.getEncounter())); 037 if (src.hasDate()) 038 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 039 if (src.hasSource()) 040 tgt.setSource(Reference30_50.convertReference(src.getSource())); 041 if (src.hasOrderedBy()) 042 tgt.setOrderedBy(CodeableConcept30_50.convertCodeableConcept(src.getOrderedBy())); 043 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 044 for (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent t : src.getEntry()) 045 tgt.addEntry(convertListEntryComponent(t)); 046 if (src.hasEmptyReason()) 047 tgt.setEmptyReason(CodeableConcept30_50.convertCodeableConcept(src.getEmptyReason())); 048 return tgt; 049 } 050 051 public static org.hl7.fhir.dstu3.model.ListResource convertList(org.hl7.fhir.r5.model.ListResource src) throws FHIRException { 052 if (src == null) 053 return null; 054 org.hl7.fhir.dstu3.model.ListResource tgt = new org.hl7.fhir.dstu3.model.ListResource(); 055 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 056 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 057 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 058 if (src.hasStatus()) 059 tgt.setStatusElement(convertListStatus(src.getStatusElement())); 060 if (src.hasMode()) 061 tgt.setModeElement(convertListMode(src.getModeElement())); 062 if (src.hasTitle()) 063 tgt.setTitleElement(String30_50.convertString(src.getTitleElement())); 064 if (src.hasCode()) 065 tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 066 if (src.hasSubject()) 067 tgt.setSubject(Reference30_50.convertReference(src.getSubjectFirstRep())); 068 if (src.hasEncounter()) 069 tgt.setEncounter(Reference30_50.convertReference(src.getEncounter())); 070 if (src.hasDate()) 071 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 072 if (src.hasSource()) 073 tgt.setSource(Reference30_50.convertReference(src.getSource())); 074 if (src.hasOrderedBy()) 075 tgt.setOrderedBy(CodeableConcept30_50.convertCodeableConcept(src.getOrderedBy())); 076 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 077 for (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent t : src.getEntry()) 078 tgt.addEntry(convertListEntryComponent(t)); 079 if (src.hasEmptyReason()) 080 tgt.setEmptyReason(CodeableConcept30_50.convertCodeableConcept(src.getEmptyReason())); 081 return tgt; 082 } 083 084 public static org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent convertListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent src) throws FHIRException { 085 if (src == null) 086 return null; 087 org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent tgt = new org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent(); 088 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 089 if (src.hasFlag()) 090 tgt.setFlag(CodeableConcept30_50.convertCodeableConcept(src.getFlag())); 091 if (src.hasDeleted()) 092 tgt.setDeletedElement(Boolean30_50.convertBoolean(src.getDeletedElement())); 093 if (src.hasDate()) 094 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 095 if (src.hasItem()) 096 tgt.setItem(Reference30_50.convertReference(src.getItem())); 097 return tgt; 098 } 099 100 public static org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent convertListEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent src) throws FHIRException { 101 if (src == null) 102 return null; 103 org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent(); 104 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 105 if (src.hasFlag()) 106 tgt.setFlag(CodeableConcept30_50.convertCodeableConcept(src.getFlag())); 107 if (src.hasDeleted()) 108 tgt.setDeletedElement(Boolean30_50.convertBoolean(src.getDeletedElement())); 109 if (src.hasDate()) 110 tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement())); 111 if (src.hasItem()) 112 tgt.setItem(Reference30_50.convertReference(src.getItem())); 113 return tgt; 114 } 115 116 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> convertListMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> src) throws FHIRException { 117 if (src == null || src.isEmpty()) 118 return null; 119 Enumeration<Enumerations.ListMode> tgt = new Enumeration<>(new Enumerations.ListModeEnumFactory()); 120 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 121 if (src.getValue() == null) { 122 tgt.setValue(null); 123 } else { 124 switch (src.getValue()) { 125 case WORKING: 126 tgt.setValue(Enumerations.ListMode.WORKING); 127 break; 128 case SNAPSHOT: 129 tgt.setValue(Enumerations.ListMode.SNAPSHOT); 130 break; 131 case CHANGES: 132 tgt.setValue(Enumerations.ListMode.CHANGES); 133 break; 134 default: 135 tgt.setValue(Enumerations.ListMode.NULL); 136 break; 137 } 138 } 139 return tgt; 140 } 141 142 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> convertListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> src) throws FHIRException { 143 if (src == null || src.isEmpty()) 144 return null; 145 org.hl7.fhir.dstu3.model.Enumeration<ListResource.ListMode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new ListResource.ListModeEnumFactory()); 146 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 147 if (src.getValue() == null) { 148 tgt.setValue(null); 149 } else { 150 switch (src.getValue()) { 151 case WORKING: 152 tgt.setValue(ListResource.ListMode.WORKING); 153 break; 154 case SNAPSHOT: 155 tgt.setValue(ListResource.ListMode.SNAPSHOT); 156 break; 157 case CHANGES: 158 tgt.setValue(ListResource.ListMode.CHANGES); 159 break; 160 default: 161 tgt.setValue(ListResource.ListMode.NULL); 162 break; 163 } 164 } 165 return tgt; 166 } 167 168 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> src) throws FHIRException { 169 if (src == null || src.isEmpty()) 170 return null; 171 Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> tgt = new Enumeration<>(new org.hl7.fhir.r5.model.ListResource.ListStatusEnumFactory()); 172 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 173 if (src.getValue() == null) { 174 tgt.setValue(null); 175 } else { 176 switch (src.getValue()) { 177 case CURRENT: 178 tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.CURRENT); 179 break; 180 case RETIRED: 181 tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.RETIRED); 182 break; 183 case ENTEREDINERROR: 184 tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.ENTEREDINERROR); 185 break; 186 default: 187 tgt.setValue(org.hl7.fhir.r5.model.ListResource.ListStatus.NULL); 188 break; 189 } 190 } 191 return tgt; 192 } 193 194 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> src) throws FHIRException { 195 if (src == null || src.isEmpty()) 196 return null; 197 org.hl7.fhir.dstu3.model.Enumeration<ListResource.ListStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new ListResource.ListStatusEnumFactory()); 198 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 199 if (src.getValue() == null) { 200 tgt.setValue(null); 201 } else { 202 switch (src.getValue()) { 203 case CURRENT: 204 tgt.setValue(ListResource.ListStatus.CURRENT); 205 break; 206 case RETIRED: 207 tgt.setValue(ListResource.ListStatus.RETIRED); 208 break; 209 case ENTEREDINERROR: 210 tgt.setValue(ListResource.ListStatus.ENTEREDINERROR); 211 break; 212 default: 213 tgt.setValue(ListResource.ListStatus.NULL); 214 break; 215 } 216 } 217 return tgt; 218 } 219}