001package org.hl7.fhir.convertors.conv10_30.resources10_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_30; 004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Extension10_30; 005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30; 006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.CodeableConcept10_30; 007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Identifier10_30; 008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Boolean10_30; 009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.DateTime10_30; 010import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 011import org.hl7.fhir.exceptions.FHIRException; 012 013public class List10_30 { 014 015 public static org.hl7.fhir.dstu2.model.List_ convertList(org.hl7.fhir.dstu3.model.ListResource src) throws FHIRException { 016 if (src == null || src.isEmpty()) 017 return null; 018 org.hl7.fhir.dstu2.model.List_ tgt = new org.hl7.fhir.dstu2.model.List_(); 019 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 020 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 021 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 022 if (src.hasTitleElement()) 023 tgt.setTitleElement(String10_30.convertString(src.getTitleElement())); 024 if (src.hasCode()) 025 tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getCode())); 026 if (src.hasSubject()) 027 tgt.setSubject(Reference10_30.convertReference(src.getSubject())); 028 if (src.hasSource()) 029 tgt.setSource(Reference10_30.convertReference(src.getSource())); 030 if (src.hasEncounter()) 031 tgt.setEncounter(Reference10_30.convertReference(src.getEncounter())); 032 if (src.hasStatus()) 033 tgt.setStatusElement(convertListStatus(src.getStatusElement())); 034 if (src.hasDate()) 035 tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement())); 036 if (src.hasOrderedBy()) 037 tgt.setOrderedBy(CodeableConcept10_30.convertCodeableConcept(src.getOrderedBy())); 038 if (src.hasMode()) 039 tgt.setModeElement(convertListMode(src.getModeElement())); 040 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.setNote(t.getText()); 041 for (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent t : src.getEntry()) tgt.addEntry(convertListEntry(t)); 042 return tgt; 043 } 044 045 public static org.hl7.fhir.dstu3.model.ListResource convertList(org.hl7.fhir.dstu2.model.List_ src) throws FHIRException { 046 if (src == null || src.isEmpty()) 047 return null; 048 org.hl7.fhir.dstu3.model.ListResource tgt = new org.hl7.fhir.dstu3.model.ListResource(); 049 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 050 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 051 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 052 if (src.hasTitleElement()) 053 tgt.setTitleElement(String10_30.convertString(src.getTitleElement())); 054 if (src.hasCode()) 055 tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getCode())); 056 if (src.hasSubject()) 057 tgt.setSubject(Reference10_30.convertReference(src.getSubject())); 058 if (src.hasSource()) 059 tgt.setSource(Reference10_30.convertReference(src.getSource())); 060 if (src.hasEncounter()) 061 tgt.setEncounter(Reference10_30.convertReference(src.getEncounter())); 062 if (src.hasStatus()) 063 tgt.setStatusElement(convertListStatus(src.getStatusElement())); 064 if (src.hasDate()) 065 tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement())); 066 if (src.hasOrderedBy()) 067 tgt.setOrderedBy(CodeableConcept10_30.convertCodeableConcept(src.getOrderedBy())); 068 if (src.hasMode()) 069 tgt.setModeElement(convertListMode(src.getModeElement())); 070 if (src.hasNote()) 071 tgt.addNote(new org.hl7.fhir.dstu3.model.Annotation().setText(src.getNote())); 072 for (org.hl7.fhir.dstu2.model.List_.ListEntryComponent t : src.getEntry()) tgt.addEntry(convertListEntry(t)); 073 return tgt; 074 } 075 076 public static org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent convertListEntry(org.hl7.fhir.dstu2.model.List_.ListEntryComponent src) throws FHIRException { 077 if (src == null || src.isEmpty()) 078 return null; 079 org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent(); 080 copyBackboneElement(src, tgt); 081 if (src.hasFlag()) 082 tgt.setFlag(CodeableConcept10_30.convertCodeableConcept(src.getFlag())); 083 if (src.hasDeletedElement()) 084 tgt.setDeletedElement(Boolean10_30.convertBoolean(src.getDeletedElement())); 085 if (src.hasDate()) 086 tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement())); 087 if (src.hasItem()) 088 tgt.setItem(Reference10_30.convertReference(src.getItem())); 089 return tgt; 090 } 091 092 public static org.hl7.fhir.dstu2.model.List_.ListEntryComponent convertListEntry(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent src) throws FHIRException { 093 if (src == null || src.isEmpty()) 094 return null; 095 org.hl7.fhir.dstu2.model.List_.ListEntryComponent tgt = new org.hl7.fhir.dstu2.model.List_.ListEntryComponent(); 096 copyBackboneElement(src, tgt); 097 if (src.hasFlag()) 098 tgt.setFlag(CodeableConcept10_30.convertCodeableConcept(src.getFlag())); 099 if (src.hasDeletedElement()) 100 tgt.setDeletedElement(Boolean10_30.convertBoolean(src.getDeletedElement())); 101 if (src.hasDate()) 102 tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement())); 103 if (src.hasItem()) 104 tgt.setItem(Reference10_30.convertReference(src.getItem())); 105 return tgt; 106 } 107 108 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> convertListMode(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.List_.ListMode> src) throws FHIRException { 109 if (src == null || src.isEmpty()) 110 return null; 111 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ListResource.ListModeEnumFactory()); 112 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 113 switch (src.getValue()) { 114 case WORKING: 115 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.WORKING); 116 break; 117 case SNAPSHOT: 118 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.SNAPSHOT); 119 break; 120 case CHANGES: 121 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.CHANGES); 122 break; 123 default: 124 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListMode.NULL); 125 break; 126 } 127 return tgt; 128 } 129 130 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.List_.ListMode> convertListMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListMode> src) throws FHIRException { 131 if (src == null || src.isEmpty()) 132 return null; 133 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.List_.ListMode> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.List_.ListModeEnumFactory()); 134 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 135 switch (src.getValue()) { 136 case WORKING: 137 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListMode.WORKING); 138 break; 139 case SNAPSHOT: 140 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListMode.SNAPSHOT); 141 break; 142 case CHANGES: 143 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListMode.CHANGES); 144 break; 145 default: 146 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListMode.NULL); 147 break; 148 } 149 return tgt; 150 } 151 152 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.List_.ListStatus> convertListStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> src) throws FHIRException { 153 if (src == null || src.isEmpty()) 154 return null; 155 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.List_.ListStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.List_.ListStatusEnumFactory()); 156 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 157 switch (src.getValue()) { 158 case CURRENT: 159 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListStatus.CURRENT); 160 break; 161 case RETIRED: 162 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListStatus.RETIRED); 163 break; 164 case ENTEREDINERROR: 165 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListStatus.ENTEREDINERROR); 166 break; 167 default: 168 tgt.setValue(org.hl7.fhir.dstu2.model.List_.ListStatus.NULL); 169 break; 170 } 171 return tgt; 172 } 173 174 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.List_.ListStatus> src) throws FHIRException { 175 if (src == null || src.isEmpty()) 176 return null; 177 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ListResource.ListStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ListResource.ListStatusEnumFactory()); 178 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 179 switch (src.getValue()) { 180 case CURRENT: 181 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.CURRENT); 182 break; 183 case RETIRED: 184 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.RETIRED); 185 break; 186 case ENTEREDINERROR: 187 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.ENTEREDINERROR); 188 break; 189 default: 190 tgt.setValue(org.hl7.fhir.dstu3.model.ListResource.ListStatus.NULL); 191 break; 192 } 193 return tgt; 194 } 195 196 public static void copyBackboneElement(org.hl7.fhir.dstu2.model.BackboneElement src, org.hl7.fhir.dstu3.model.BackboneElement tgt) throws FHIRException { 197 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 198 for (org.hl7.fhir.dstu2.model.Extension e : src.getModifierExtension()) { 199 tgt.addModifierExtension(Extension10_30.convertExtension(e)); 200 } 201 } 202 203 public static void copyBackboneElement(org.hl7.fhir.dstu3.model.BackboneElement src, org.hl7.fhir.dstu2.model.BackboneElement tgt) throws FHIRException { 204 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt); 205 for (org.hl7.fhir.dstu3.model.Extension e : src.getModifierExtension()) { 206 tgt.addModifierExtension(Extension10_30.convertExtension(e)); 207 } 208 } 209}