
001package org.hl7.fhir.convertors.conv10_40.resources10_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_40; 004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40; 005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Instant10_40; 006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40; 007import org.hl7.fhir.exceptions.FHIRException; 008 009public class Subscription10_40 { 010 011 public static org.hl7.fhir.r4.model.Subscription convertSubscription(org.hl7.fhir.dstu2.model.Subscription src) throws FHIRException { 012 if (src == null || src.isEmpty()) 013 return null; 014 org.hl7.fhir.r4.model.Subscription tgt = new org.hl7.fhir.r4.model.Subscription(); 015 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 016 if (src.hasCriteriaElement()) 017 tgt.setCriteriaElement(String10_40.convertString(src.getCriteriaElement())); 018 for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getContact()) 019 tgt.addContact(ContactPoint10_40.convertContactPoint(t)); 020 if (src.hasReasonElement()) 021 tgt.setReasonElement(String10_40.convertString(src.getReasonElement())); 022 if (src.hasStatus()) 023 tgt.setStatusElement(convertSubscriptionStatus(src.getStatusElement())); 024 if (src.hasErrorElement()) 025 tgt.setErrorElement(String10_40.convertString(src.getErrorElement())); 026 if (src.hasChannel()) 027 tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); 028 if (src.hasEndElement()) 029 tgt.setEndElement(Instant10_40.convertInstant(src.getEndElement())); 030 return tgt; 031 } 032 033 public static org.hl7.fhir.dstu2.model.Subscription convertSubscription(org.hl7.fhir.r4.model.Subscription src) throws FHIRException { 034 if (src == null || src.isEmpty()) 035 return null; 036 org.hl7.fhir.dstu2.model.Subscription tgt = new org.hl7.fhir.dstu2.model.Subscription(); 037 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 038 if (src.hasCriteriaElement()) 039 tgt.setCriteriaElement(String10_40.convertString(src.getCriteriaElement())); 040 for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact()) 041 tgt.addContact(ContactPoint10_40.convertContactPoint(t)); 042 if (src.hasReasonElement()) 043 tgt.setReasonElement(String10_40.convertString(src.getReasonElement())); 044 if (src.hasStatus()) 045 tgt.setStatusElement(convertSubscriptionStatus(src.getStatusElement())); 046 if (src.hasErrorElement()) 047 tgt.setErrorElement(String10_40.convertString(src.getErrorElement())); 048 if (src.hasChannel()) 049 tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); 050 if (src.hasEndElement()) 051 tgt.setEndElement(Instant10_40.convertInstant(src.getEndElement())); 052 return tgt; 053 } 054 055 public static org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { 056 if (src == null || src.isEmpty()) 057 return null; 058 org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent(); 059 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 060 if (src.hasType()) 061 tgt.setTypeElement(convertSubscriptionChannelType(src.getTypeElement())); 062 if (src.hasEndpoint()) 063 tgt.setEndpoint(src.getEndpoint()); 064 if (src.hasPayload()) 065 tgt.setPayload(src.getPayload()); 066 tgt.addHeader(src.getHeader()); 067 return tgt; 068 } 069 070 public static org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { 071 if (src == null || src.isEmpty()) 072 return null; 073 org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelComponent(); 074 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 075 if (src.hasType()) 076 tgt.setTypeElement(convertSubscriptionChannelType(src.getTypeElement())); 077 if (src.hasEndpoint()) 078 tgt.setEndpoint(src.getEndpoint()); 079 if (src.hasPayload()) 080 tgt.setPayload(src.getPayload()); 081 if (src.hasHeader()) 082 tgt.setHeaderElement(String10_40.convertString(src.getHeader().get(0))); 083 return tgt; 084 } 085 086 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType> convertSubscriptionChannelType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType> src) throws FHIRException { 087 if (src == null || src.isEmpty()) 088 return null; 089 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelTypeEnumFactory()); 090 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 091 switch (src.getValue()) { 092 case RESTHOOK: 093 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.RESTHOOK); 094 break; 095 case WEBSOCKET: 096 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.WEBSOCKET); 097 break; 098 case EMAIL: 099 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.EMAIL); 100 break; 101 case SMS: 102 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.SMS); 103 break; 104 case MESSAGE: 105 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.MESSAGE); 106 break; 107 default: 108 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType.NULL); 109 break; 110 } 111 return tgt; 112 } 113 114 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType> convertSubscriptionChannelType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Subscription.SubscriptionChannelType> src) throws FHIRException { 115 if (src == null || src.isEmpty()) 116 return null; 117 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Subscription.SubscriptionChannelTypeEnumFactory()); 118 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 119 switch (src.getValue()) { 120 case RESTHOOK: 121 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.RESTHOOK); 122 break; 123 case WEBSOCKET: 124 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.WEBSOCKET); 125 break; 126 case EMAIL: 127 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.EMAIL); 128 break; 129 case SMS: 130 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.SMS); 131 break; 132 case MESSAGE: 133 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.MESSAGE); 134 break; 135 default: 136 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.NULL); 137 break; 138 } 139 return tgt; 140 } 141 142 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionStatus> convertSubscriptionStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus> src) throws FHIRException { 143 if (src == null || src.isEmpty()) 144 return null; 145 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Subscription.SubscriptionStatusEnumFactory()); 146 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 147 switch (src.getValue()) { 148 case REQUESTED: 149 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.REQUESTED); 150 break; 151 case ACTIVE: 152 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ACTIVE); 153 break; 154 case ERROR: 155 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ERROR); 156 break; 157 case OFF: 158 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.OFF); 159 break; 160 default: 161 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.NULL); 162 break; 163 } 164 return tgt; 165 } 166 167 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus> convertSubscriptionStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionStatus> src) throws FHIRException { 168 if (src == null || src.isEmpty()) 169 return null; 170 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatusEnumFactory()); 171 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 172 switch (src.getValue()) { 173 case REQUESTED: 174 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus.REQUESTED); 175 break; 176 case ACTIVE: 177 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus.ACTIVE); 178 break; 179 case ERROR: 180 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus.ERROR); 181 break; 182 case OFF: 183 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus.OFF); 184 break; 185 default: 186 tgt.setValue(org.hl7.fhir.dstu2.model.Subscription.SubscriptionStatus.NULL); 187 break; 188 } 189 return tgt; 190 } 191}