001package org.hl7.fhir.convertors.conv43_50.resources43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 008import org.hl7.fhir.exceptions.FHIRException; 009 010/* 011 Copyright (c) 2011+, HL7, Inc. 012 All rights reserved. 013 014 Redistribution and use in source and binary forms, with or without modification, 015 are permitted provided that the following conditions are met: 016 017 * Redistributions of source code must retain the above copyright notice, this 018 list of conditions and the following disclaimer. 019 * Redistributions in binary form must reproduce the above copyright notice, 020 this list of conditions and the following disclaimer in the documentation 021 and/or other materials provided with the distribution. 022 * Neither the name of HL7 nor the names of its contributors may be used to 023 endorse or promote products derived from this software without specific 024 prior written permission. 025 026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 027 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 028 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 029 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 030 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 031 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 032 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 033 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 034 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 035 POSSIBILITY OF SUCH DAMAGE. 036 037*/ 038// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 039public class Flag43_50 { 040 041 public static org.hl7.fhir.r5.model.Flag convertFlag(org.hl7.fhir.r4b.model.Flag src) throws FHIRException { 042 if (src == null) 043 return null; 044 org.hl7.fhir.r5.model.Flag tgt = new org.hl7.fhir.r5.model.Flag(); 045 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 046 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 047 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 048 if (src.hasStatus()) 049 tgt.setStatusElement(convertFlagStatus(src.getStatusElement())); 050 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCategory()) 051 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t)); 052 if (src.hasCode()) 053 tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode())); 054 if (src.hasSubject()) 055 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 056 if (src.hasPeriod()) 057 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 058 if (src.hasEncounter()) 059 tgt.setEncounter(Reference43_50.convertReference(src.getEncounter())); 060 if (src.hasAuthor()) 061 tgt.setAuthor(Reference43_50.convertReference(src.getAuthor())); 062 return tgt; 063 } 064 065 public static org.hl7.fhir.r4b.model.Flag convertFlag(org.hl7.fhir.r5.model.Flag src) throws FHIRException { 066 if (src == null) 067 return null; 068 org.hl7.fhir.r4b.model.Flag tgt = new org.hl7.fhir.r4b.model.Flag(); 069 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 070 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 071 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 072 if (src.hasStatus()) 073 tgt.setStatusElement(convertFlagStatus(src.getStatusElement())); 074 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 075 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t)); 076 if (src.hasCode()) 077 tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode())); 078 if (src.hasSubject()) 079 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 080 if (src.hasPeriod()) 081 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 082 if (src.hasEncounter()) 083 tgt.setEncounter(Reference43_50.convertReference(src.getEncounter())); 084 if (src.hasAuthor()) 085 tgt.setAuthor(Reference43_50.convertReference(src.getAuthor())); 086 return tgt; 087 } 088 089 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Flag.FlagStatus> convertFlagStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Flag.FlagStatus> src) throws FHIRException { 090 if (src == null || src.isEmpty()) 091 return null; 092 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Flag.FlagStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Flag.FlagStatusEnumFactory()); 093 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 094 switch (src.getValue()) { 095 case ACTIVE: 096 tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.ACTIVE); 097 break; 098 case INACTIVE: 099 tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.INACTIVE); 100 break; 101 case ENTEREDINERROR: 102 tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.ENTEREDINERROR); 103 break; 104 default: 105 tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.NULL); 106 break; 107 } 108 return tgt; 109 } 110 111 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Flag.FlagStatus> convertFlagStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Flag.FlagStatus> src) throws FHIRException { 112 if (src == null || src.isEmpty()) 113 return null; 114 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Flag.FlagStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Flag.FlagStatusEnumFactory()); 115 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 116 switch (src.getValue()) { 117 case ACTIVE: 118 tgt.setValue(org.hl7.fhir.r4b.model.Flag.FlagStatus.ACTIVE); 119 break; 120 case INACTIVE: 121 tgt.setValue(org.hl7.fhir.r4b.model.Flag.FlagStatus.INACTIVE); 122 break; 123 case ENTEREDINERROR: 124 tgt.setValue(org.hl7.fhir.r4b.model.Flag.FlagStatus.ENTEREDINERROR); 125 break; 126 default: 127 tgt.setValue(org.hl7.fhir.r4b.model.Flag.FlagStatus.NULL); 128 break; 129 } 130 return tgt; 131 } 132}