001package org.hl7.fhir.convertors.conv10_30;
002
003import java.util.List;
004import org.hl7.fhir.convertors.VersionConvertorAdvisor30;
005import org.hl7.fhir.convertors.VersionConvertor_10_30;
006import org.hl7.fhir.dstu2.model.ValueSet;
007import org.hl7.fhir.dstu3.model.CodeSystem;
008import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
009import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
010import org.hl7.fhir.dstu3.terminologies.CodeSystemUtilities;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class ValueSet10_30 {
014
015    public static org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
016        if (src == null || src.isEmpty())
017            return null;
018        org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent();
019        VersionConvertor_10_30.copyElement(src, tgt);
020        if (src.hasCodeElement())
021            tgt.setCodeElement(VersionConvertor_10_30.convertCode(src.getCodeElement()));
022        if (src.hasDisplayElement())
023            tgt.setDisplayElement(VersionConvertor_10_30.convertString(src.getDisplayElement()));
024        for (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent t : src.getDesignation()) tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
025        return tgt;
026    }
027
028    public static org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent convertConceptReferenceComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent src) throws FHIRException {
029        if (src == null || src.isEmpty())
030            return null;
031        org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent();
032        VersionConvertor_10_30.copyElement(src, tgt);
033        if (src.hasCodeElement())
034            tgt.setCodeElement(VersionConvertor_10_30.convertCode(src.getCodeElement()));
035        if (src.hasDisplayElement())
036            tgt.setDisplayElement(VersionConvertor_10_30.convertString(src.getDisplayElement()));
037        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent t : src.getDesignation()) tgt.addDesignation(convertConceptReferenceDesignationComponent(t));
038        return tgt;
039    }
040
041    public static org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent src) throws FHIRException {
042        if (src == null || src.isEmpty())
043            return null;
044        org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent();
045        VersionConvertor_10_30.copyElement(src, tgt);
046        if (src.hasLanguageElement())
047            tgt.setLanguageElement(VersionConvertor_10_30.convertCode(src.getLanguageElement()));
048        if (src.hasUse())
049            tgt.setUse(VersionConvertor_10_30.convertCoding(src.getUse()));
050        if (src.hasValueElement())
051            tgt.setValueElement(VersionConvertor_10_30.convertString(src.getValueElement()));
052        return tgt;
053    }
054
055    public static org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent convertConceptReferenceDesignationComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent src) throws FHIRException {
056        if (src == null || src.isEmpty())
057            return null;
058        org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent();
059        VersionConvertor_10_30.copyElement(src, tgt);
060        if (src.hasLanguageElement())
061            tgt.setLanguageElement(VersionConvertor_10_30.convertCode(src.getLanguageElement()));
062        if (src.hasUse())
063            tgt.setUse(VersionConvertor_10_30.convertCoding(src.getUse()));
064        if (src.hasValueElement())
065            tgt.setValueElement(VersionConvertor_10_30.convertString(src.getValueElement()));
066        return tgt;
067    }
068
069    public static org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent src) throws FHIRException {
070        if (src == null || src.isEmpty())
071            return null;
072        org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent();
073        VersionConvertor_10_30.copyElement(src, tgt);
074        if (src.hasSystemElement())
075            tgt.setSystemElement(VersionConvertor_10_30.convertUri(src.getSystemElement()));
076        if (src.hasVersionElement())
077            tgt.setVersionElement(VersionConvertor_10_30.convertString(src.getVersionElement()));
078        for (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) tgt.addConcept(convertConceptReferenceComponent(t));
079        for (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) tgt.addFilter(convertConceptSetFilterComponent(t));
080        return tgt;
081    }
082
083    public static org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent convertConceptSetComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent src) throws FHIRException {
084        if (src == null || src.isEmpty())
085            return null;
086        org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent();
087        VersionConvertor_10_30.copyElement(src, tgt);
088        if (src.hasSystemElement())
089            tgt.setSystemElement(VersionConvertor_10_30.convertUri(src.getSystemElement()));
090        if (src.hasVersionElement())
091            tgt.setVersionElement(VersionConvertor_10_30.convertString(src.getVersionElement()));
092        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent t : src.getConcept()) tgt.addConcept(convertConceptReferenceComponent(t));
093        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent t : src.getFilter()) tgt.addFilter(convertConceptSetFilterComponent(t));
094        return tgt;
095    }
096
097    public static org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException {
098        if (src == null || src.isEmpty())
099            return null;
100        org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent();
101        VersionConvertor_10_30.copyElement(src, tgt);
102        if (src.hasPropertyElement())
103            tgt.setPropertyElement(VersionConvertor_10_30.convertCode(src.getPropertyElement()));
104        if (src.hasOp())
105            tgt.setOpElement(convertFilterOperator(src.getOpElement()));
106        if (src.hasValueElement())
107            tgt.setValueElement(VersionConvertor_10_30.convertCode(src.getValueElement()));
108        return tgt;
109    }
110
111    public static org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent convertConceptSetFilterComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent src) throws FHIRException {
112        if (src == null || src.isEmpty())
113            return null;
114        org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent();
115        VersionConvertor_10_30.copyElement(src, tgt);
116        if (src.hasPropertyElement())
117            tgt.setPropertyElement(VersionConvertor_10_30.convertCode(src.getPropertyElement()));
118        if (src.hasOp())
119            tgt.setOpElement(convertFilterOperator(src.getOpElement()));
120        if (src.hasValueElement())
121            tgt.setValueElement(VersionConvertor_10_30.convertCode(src.getValueElement()));
122        return tgt;
123    }
124
125    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ValueSet.FilterOperator> convertFilterOperator(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ValueSet.FilterOperator> src) throws FHIRException {
126        if (src == null || src.isEmpty())
127            return null;
128        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ValueSet.FilterOperator> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ValueSet.FilterOperatorEnumFactory());
129        VersionConvertor_10_30.copyElement(src, tgt);
130        switch(src.getValue()) {
131            case EQUAL:
132                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.EQUAL);
133                break;
134            case ISA:
135                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISA);
136                break;
137            case ISNOTA:
138                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.ISNOTA);
139                break;
140            case REGEX:
141                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.REGEX);
142                break;
143            case IN:
144                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.IN);
145                break;
146            case NOTIN:
147                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NOTIN);
148                break;
149            default:
150                tgt.setValue(org.hl7.fhir.dstu3.model.ValueSet.FilterOperator.NULL);
151                break;
152        }
153        return tgt;
154    }
155
156    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ValueSet.FilterOperator> convertFilterOperator(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ValueSet.FilterOperator> src) throws FHIRException {
157        if (src == null || src.isEmpty())
158            return null;
159        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ValueSet.FilterOperator> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ValueSet.FilterOperatorEnumFactory());
160        VersionConvertor_10_30.copyElement(src, tgt);
161        switch(src.getValue()) {
162            case EQUAL:
163                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.EQUAL);
164                break;
165            case ISA:
166                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.ISA);
167                break;
168            case ISNOTA:
169                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.ISNOTA);
170                break;
171            case REGEX:
172                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.REGEX);
173                break;
174            case IN:
175                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.IN);
176                break;
177            case NOTIN:
178                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.NOTIN);
179                break;
180            default:
181                tgt.setValue(org.hl7.fhir.dstu2.model.ValueSet.FilterOperator.NULL);
182                break;
183        }
184        return tgt;
185    }
186
187    public static org.hl7.fhir.dstu3.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src, VersionConvertorAdvisor30 advisor) throws FHIRException {
188        if (src == null || src.isEmpty())
189            return null;
190        org.hl7.fhir.dstu3.model.ValueSet tgt = new org.hl7.fhir.dstu3.model.ValueSet();
191        VersionConvertor_10_30.copyDomainResource(src, tgt);
192        if (src.hasUrlElement())
193            tgt.setUrlElement(VersionConvertor_10_30.convertUri(src.getUrlElement()));
194        if (src.hasIdentifier())
195            tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(src.getIdentifier()));
196        if (src.hasVersionElement())
197            tgt.setVersionElement(VersionConvertor_10_30.convertString(src.getVersionElement()));
198        if (src.hasNameElement())
199            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
200        if (src.hasStatus())
201            tgt.setStatusElement(VersionConvertor_10_30.convertConformanceResourceStatus(src.getStatusElement()));
202        if (src.hasExperimental())
203            tgt.setExperimentalElement(VersionConvertor_10_30.convertBoolean(src.getExperimentalElement()));
204        if (src.hasPublisherElement())
205            tgt.setPublisherElement(VersionConvertor_10_30.convertString(src.getPublisherElement()));
206        for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent t : src.getContact()) tgt.addContact(convertValueSetContactComponent(t));
207        if (src.hasDate())
208            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
209        if (src.hasDescription())
210            tgt.setDescription(src.getDescription());
211        for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) if (VersionConvertor_10_30.isJurisdiction(t))
212            tgt.addJurisdiction(VersionConvertor_10_30.convertCodeableConcept(t));
213        else
214            tgt.addUseContext(VersionConvertor_10_30.convertCodeableConceptToUsageContext(t));
215        if (src.hasImmutableElement())
216            tgt.setImmutableElement(VersionConvertor_10_30.convertBoolean(src.getImmutableElement()));
217        if (src.hasRequirements())
218            tgt.setPurpose(src.getRequirements());
219        if (src.hasCopyright())
220            tgt.setCopyright(src.getCopyright());
221        if (src.hasExtensibleElement())
222            tgt.setExtensibleElement(VersionConvertor_10_30.convertBoolean(src.getExtensibleElement()));
223        if (src.hasCompose()) {
224            if (src.hasCompose())
225                tgt.setCompose(convertValueSetComposeComponent(src.getCompose()));
226            tgt.getCompose().setLockedDate(src.getLockedDate());
227        }
228        if (src.hasCodeSystem() && advisor != null) {
229            org.hl7.fhir.dstu3.model.CodeSystem tgtcs = new org.hl7.fhir.dstu3.model.CodeSystem();
230            VersionConvertor_10_30.copyDomainResource(src, tgtcs);
231            tgtcs.setUrl(src.getCodeSystem().getSystem());
232            tgtcs.setIdentifier(VersionConvertor_10_30.convertIdentifier(src.getIdentifier()));
233            tgtcs.setVersion(src.getCodeSystem().getVersion());
234            tgtcs.setName(src.getName() + " Code System");
235            tgtcs.setStatusElement(VersionConvertor_10_30.convertConformanceResourceStatus(src.getStatusElement()));
236            if (src.hasExperimental())
237                tgtcs.setExperimental(src.getExperimental());
238            tgtcs.setPublisher(src.getPublisher());
239            for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent t : src.getContact()) tgtcs.addContact(convertValueSetContactComponent(t));
240            if (src.hasDate())
241                tgtcs.setDate(src.getDate());
242            tgtcs.setDescription(src.getDescription());
243            for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) if (VersionConvertor_10_30.isJurisdiction(t))
244                tgtcs.addJurisdiction(VersionConvertor_10_30.convertCodeableConcept(t));
245            else
246                tgtcs.addUseContext(VersionConvertor_10_30.convertCodeableConceptToUsageContext(t));
247            tgtcs.setPurpose(src.getRequirements());
248            tgtcs.setCopyright(src.getCopyright());
249            tgtcs.setContent(CodeSystemContentMode.COMPLETE);
250            tgtcs.setCaseSensitive(src.getCodeSystem().getCaseSensitive());
251            for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs : src.getCodeSystem().getConcept()) processConcept(tgtcs.getConcept(), cs, tgtcs);
252            advisor.handleCodeSystem(tgtcs, tgt);
253            tgt.setUserData("r2-cs", tgtcs);
254            tgt.getCompose().addInclude().setSystem(tgtcs.getUrl());
255        }
256        if (src.hasExpansion())
257            tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion()));
258        return tgt;
259    }
260
261    public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.dstu3.model.ValueSet src, VersionConvertorAdvisor30 advisor) throws FHIRException {
262        if (src == null || src.isEmpty())
263            return null;
264        org.hl7.fhir.dstu2.model.ValueSet tgt = new org.hl7.fhir.dstu2.model.ValueSet();
265        VersionConvertor_10_30.copyDomainResource(src, tgt);
266        if (src.hasUrlElement())
267            tgt.setUrlElement(VersionConvertor_10_30.convertUri(src.getUrlElement()));
268        for (org.hl7.fhir.dstu3.model.Identifier i : src.getIdentifier()) tgt.setIdentifier(VersionConvertor_10_30.convertIdentifier(i));
269        if (src.hasVersionElement())
270            tgt.setVersionElement(VersionConvertor_10_30.convertString(src.getVersionElement()));
271        if (src.hasNameElement())
272            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
273        if (src.hasStatus())
274            tgt.setStatusElement(VersionConvertor_10_30.convertConformanceResourceStatus(src.getStatusElement()));
275        if (src.hasExperimental())
276            tgt.setExperimentalElement(VersionConvertor_10_30.convertBoolean(src.getExperimentalElement()));
277        if (src.hasPublisherElement())
278            tgt.setPublisherElement(VersionConvertor_10_30.convertString(src.getPublisherElement()));
279        for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) tgt.addContact(convertValueSetContactComponent(t));
280        if (src.hasDate())
281            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
282        tgt.setLockedDate(src.getCompose().getLockedDate());
283        if (src.hasDescription())
284            tgt.setDescription(src.getDescription());
285        for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext()) if (t.hasValueCodeableConcept())
286            tgt.addUseContext(VersionConvertor_10_30.convertCodeableConcept(t.getValueCodeableConcept()));
287        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(VersionConvertor_10_30.convertCodeableConcept(t));
288        if (src.hasImmutableElement())
289            tgt.setImmutableElement(VersionConvertor_10_30.convertBoolean(src.getImmutableElement()));
290        if (src.hasPurpose())
291            tgt.setRequirements(src.getPurpose());
292        if (src.hasCopyright())
293            tgt.setCopyright(src.getCopyright());
294        if (src.hasExtensibleElement())
295            tgt.setExtensibleElement(VersionConvertor_10_30.convertBoolean(src.getExtensibleElement()));
296        org.hl7.fhir.dstu3.model.CodeSystem srcCS = (CodeSystem) src.getUserData("r2-cs");
297        if (srcCS == null)
298            srcCS = advisor.getCodeSystem(src);
299        if (srcCS != null) {
300            tgt.getCodeSystem().setSystem(srcCS.getUrl());
301            tgt.getCodeSystem().setVersion(srcCS.getVersion());
302            tgt.getCodeSystem().setCaseSensitive(srcCS.getCaseSensitive());
303            for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent cs : srcCS.getConcept()) processConcept(tgt.getCodeSystem().getConcept(), cs, srcCS);
304        }
305        if (src.hasCompose())
306            tgt.setCompose(convertValueSetComposeComponent(src.getCompose(), srcCS == null ? null : srcCS.getUrl()));
307        if (src.hasExpansion())
308            tgt.setExpansion(convertValueSetExpansionComponent(src.getExpansion()));
309        return tgt;
310    }
311
312    public static org.hl7.fhir.dstu3.model.ValueSet convertValueSet(org.hl7.fhir.dstu2.model.ValueSet src) throws FHIRException {
313        return convertValueSet(src, null);
314    }
315
316    public static org.hl7.fhir.dstu2.model.ValueSet convertValueSet(org.hl7.fhir.dstu3.model.ValueSet src) throws FHIRException {
317        return convertValueSet(src, null);
318    }
319
320    public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent src) throws FHIRException {
321        if (src == null || src.isEmpty())
322            return null;
323        org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent();
324        VersionConvertor_10_30.copyElement(src, tgt);
325        for (org.hl7.fhir.dstu2.model.UriType t : src.getImport()) tgt.addInclude().addValueSet(t.getValue());
326        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent t : src.getInclude()) tgt.addInclude(convertConceptSetComponent(t));
327        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent t : src.getExclude()) tgt.addExclude(convertConceptSetComponent(t));
328        return tgt;
329    }
330
331    public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent convertValueSetComposeComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent src, String noSystem) throws FHIRException {
332        if (src == null || src.isEmpty())
333            return null;
334        org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent();
335        VersionConvertor_10_30.copyElement(src, tgt);
336        for (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent t : src.getInclude()) {
337            for (org.hl7.fhir.dstu3.model.UriType ti : t.getValueSet()) tgt.addImport(ti.getValue());
338            if (noSystem == null || !t.getSystem().equals(noSystem))
339                tgt.addInclude(convertConceptSetComponent(t));
340        }
341        for (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent t : src.getExclude()) tgt.addExclude(convertConceptSetComponent(t));
342        return tgt;
343    }
344
345    public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent convertValueSetContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException {
346        if (src == null || src.isEmpty())
347            return null;
348        org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent();
349        VersionConvertor_10_30.copyElement(src, tgt);
350        if (src.hasNameElement())
351            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
352        for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_10_30.convertContactPoint(t));
353        return tgt;
354    }
355
356    public static org.hl7.fhir.dstu3.model.ContactDetail convertValueSetContactComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetContactComponent src) throws FHIRException {
357        if (src == null || src.isEmpty())
358            return null;
359        org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail();
360        VersionConvertor_10_30.copyElement(src, tgt);
361        if (src.hasNameElement())
362            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
363        for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_10_30.convertContactPoint(t));
364        return tgt;
365    }
366
367    public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException {
368        if (src == null || src.isEmpty())
369            return null;
370        org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent();
371        VersionConvertor_10_30.copyElement(src, tgt);
372        if (src.hasIdentifierElement())
373            tgt.setIdentifierElement(VersionConvertor_10_30.convertUri(src.getIdentifierElement()));
374        if (src.hasTimestampElement())
375            tgt.setTimestampElement(VersionConvertor_10_30.convertDateTime(src.getTimestampElement()));
376        if (src.hasTotalElement())
377            tgt.setTotalElement(VersionConvertor_10_30.convertInteger(src.getTotalElement()));
378        if (src.hasOffsetElement())
379            tgt.setOffsetElement(VersionConvertor_10_30.convertInteger(src.getOffsetElement()));
380        for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) tgt.addParameter(convertValueSetExpansionParameterComponent(t));
381        for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) tgt.addContains(convertValueSetExpansionContainsComponent(t));
382        return tgt;
383    }
384
385    public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent convertValueSetExpansionComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent src) throws FHIRException {
386        if (src == null || src.isEmpty())
387            return null;
388        org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent();
389        VersionConvertor_10_30.copyElement(src, tgt);
390        if (src.hasIdentifierElement())
391            tgt.setIdentifierElement(VersionConvertor_10_30.convertUri(src.getIdentifierElement()));
392        if (src.hasTimestampElement())
393            tgt.setTimestampElement(VersionConvertor_10_30.convertDateTime(src.getTimestampElement()));
394        if (src.hasTotalElement())
395            tgt.setTotalElement(VersionConvertor_10_30.convertInteger(src.getTotalElement()));
396        if (src.hasOffsetElement())
397            tgt.setOffsetElement(VersionConvertor_10_30.convertInteger(src.getOffsetElement()));
398        for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent t : src.getParameter()) tgt.addParameter(convertValueSetExpansionParameterComponent(t));
399        for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) tgt.addContains(convertValueSetExpansionContainsComponent(t));
400        return tgt;
401    }
402
403    public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException {
404        if (src == null || src.isEmpty())
405            return null;
406        org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent();
407        VersionConvertor_10_30.copyElement(src, tgt);
408        if (src.hasSystemElement())
409            tgt.setSystemElement(VersionConvertor_10_30.convertUri(src.getSystemElement()));
410        if (src.hasAbstractElement())
411            tgt.setAbstractElement(VersionConvertor_10_30.convertBoolean(src.getAbstractElement()));
412        if (src.hasVersionElement())
413            tgt.setVersionElement(VersionConvertor_10_30.convertString(src.getVersionElement()));
414        if (src.hasCodeElement())
415            tgt.setCodeElement(VersionConvertor_10_30.convertCode(src.getCodeElement()));
416        if (src.hasDisplayElement())
417            tgt.setDisplayElement(VersionConvertor_10_30.convertString(src.getDisplayElement()));
418        for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) tgt.addContains(convertValueSetExpansionContainsComponent(t));
419        return tgt;
420    }
421
422    public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent convertValueSetExpansionContainsComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent src) throws FHIRException {
423        if (src == null || src.isEmpty())
424            return null;
425        org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent();
426        VersionConvertor_10_30.copyElement(src, tgt);
427        if (src.hasSystemElement())
428            tgt.setSystemElement(VersionConvertor_10_30.convertUri(src.getSystemElement()));
429        if (src.hasAbstractElement())
430            tgt.setAbstractElement(VersionConvertor_10_30.convertBoolean(src.getAbstractElement()));
431        if (src.hasVersionElement())
432            tgt.setVersionElement(VersionConvertor_10_30.convertString(src.getVersionElement()));
433        if (src.hasCodeElement())
434            tgt.setCodeElement(VersionConvertor_10_30.convertCode(src.getCodeElement()));
435        if (src.hasDisplayElement())
436            tgt.setDisplayElement(VersionConvertor_10_30.convertString(src.getDisplayElement()));
437        for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent t : src.getContains()) tgt.addContains(convertValueSetExpansionContainsComponent(t));
438        return tgt;
439    }
440
441    public static org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException {
442        if (src == null || src.isEmpty())
443            return null;
444        org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent();
445        VersionConvertor_10_30.copyElement(src, tgt);
446        if (src.hasNameElement())
447            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
448        if (src.hasValue())
449            tgt.setValue(VersionConvertor_10_30.convertType(src.getValue()));
450        return tgt;
451    }
452
453    public static org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent convertValueSetExpansionParameterComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent src) throws FHIRException {
454        if (src == null || src.isEmpty())
455            return null;
456        org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent tgt = new org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionParameterComponent();
457        VersionConvertor_10_30.copyElement(src, tgt);
458        if (src.hasNameElement())
459            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
460        if (src.hasValue())
461            tgt.setValue(VersionConvertor_10_30.convertType(src.getValue()));
462        return tgt;
463    }
464
465    static public void processConcept(List<ConceptDefinitionComponent> concepts, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException {
466        org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent();
467        concepts.add(ct);
468        ct.setCode(cs.getCode());
469        ct.setDisplay(cs.getDisplay());
470        ct.setDefinition(cs.getDefinition());
471        if (cs.getAbstract())
472            CodeSystemUtilities.setNotSelectable(tgtcs, ct);
473        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
474            org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent();
475            cst.setLanguage(csd.getLanguage());
476            cst.setUse(VersionConvertor_10_30.convertCoding(csd.getUse()));
477            cst.setValue(csd.getValue());
478        }
479        for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, tgtcs);
480    }
481
482    static public void processConcept(List<ValueSet.ConceptDefinitionComponent> concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException {
483        org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent();
484        concepts.add(ct);
485        ct.setCode(cs.getCode());
486        ct.setDisplay(cs.getDisplay());
487        ct.setDefinition(cs.getDefinition());
488        if (CodeSystemUtilities.isNotSelectable(srcCS, cs))
489            ct.setAbstract(true);
490        for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
491            org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent();
492            cst.setLanguage(csd.getLanguage());
493            cst.setUse(VersionConvertor_10_30.convertCoding(csd.getUse()));
494            cst.setValue(csd.getValue());
495        }
496        for (ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, srcCS);
497    }
498}