001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.ContactPoint30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Instant30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40; 007import org.hl7.fhir.exceptions.FHIRException; 008 009public class Subscription30_40 { 010 011 public static org.hl7.fhir.r4.model.Subscription convertSubscription(org.hl7.fhir.dstu3.model.Subscription src) throws FHIRException { 012 if (src == null) 013 return null; 014 org.hl7.fhir.r4.model.Subscription tgt = new org.hl7.fhir.r4.model.Subscription(); 015 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 016 if (src.hasStatus()) 017 tgt.setStatusElement(convertSubscriptionStatus(src.getStatusElement())); 018 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getContact()) 019 tgt.addContact(ContactPoint30_40.convertContactPoint(t)); 020 if (src.hasEnd()) 021 tgt.setEndElement(Instant30_40.convertInstant(src.getEndElement())); 022 if (src.hasReason()) 023 tgt.setReasonElement(String30_40.convertString(src.getReasonElement())); 024 if (src.hasCriteria()) 025 tgt.setCriteriaElement(String30_40.convertString(src.getCriteriaElement())); 026 if (src.hasError()) 027 tgt.setErrorElement(String30_40.convertString(src.getErrorElement())); 028 if (src.hasChannel()) 029 tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); 030 return tgt; 031 } 032 033 public static org.hl7.fhir.dstu3.model.Subscription convertSubscription(org.hl7.fhir.r4.model.Subscription src) throws FHIRException { 034 if (src == null) 035 return null; 036 org.hl7.fhir.dstu3.model.Subscription tgt = new org.hl7.fhir.dstu3.model.Subscription(); 037 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 038 if (src.hasStatus()) 039 tgt.setStatusElement(convertSubscriptionStatus(src.getStatusElement())); 040 for (org.hl7.fhir.r4.model.ContactPoint t : src.getContact()) 041 tgt.addContact(ContactPoint30_40.convertContactPoint(t)); 042 if (src.hasEnd()) 043 tgt.setEndElement(Instant30_40.convertInstant(src.getEndElement())); 044 if (src.hasReason()) 045 tgt.setReasonElement(String30_40.convertString(src.getReasonElement())); 046 if (src.hasCriteria()) 047 tgt.setCriteriaElement(String30_40.convertString(src.getCriteriaElement())); 048 if (src.hasError()) 049 tgt.setErrorElement(String30_40.convertString(src.getErrorElement())); 050 if (src.hasChannel()) 051 tgt.setChannel(convertSubscriptionChannelComponent(src.getChannel())); 052 return tgt; 053 } 054 055 public static org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { 056 if (src == null) 057 return null; 058 org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent(); 059 ConversionContext30_40.INSTANCE.getVersionConvertor_30_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 for (org.hl7.fhir.r4.model.StringType t : src.getHeader()) tgt.addHeader(t.getValue()); 067 return tgt; 068 } 069 070 public static org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent convertSubscriptionChannelComponent(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelComponent src) throws FHIRException { 071 if (src == null) 072 return null; 073 org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent tgt = new org.hl7.fhir.r4.model.Subscription.SubscriptionChannelComponent(); 074 ConversionContext30_40.INSTANCE.getVersionConvertor_30_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 for (org.hl7.fhir.dstu3.model.StringType t : src.getHeader()) tgt.addHeader(t.getValue()); 082 return tgt; 083 } 084 085 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType> convertSubscriptionChannelType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType> src) throws FHIRException { 086 if (src == null || src.isEmpty()) 087 return null; 088 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelTypeEnumFactory()); 089 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 090 switch (src.getValue()) { 091 case RESTHOOK: 092 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.RESTHOOK); 093 break; 094 case WEBSOCKET: 095 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.WEBSOCKET); 096 break; 097 case EMAIL: 098 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.EMAIL); 099 break; 100 case SMS: 101 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.SMS); 102 break; 103 case MESSAGE: 104 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.MESSAGE); 105 break; 106 default: 107 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType.NULL); 108 break; 109 } 110 return tgt; 111 } 112 113 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType> convertSubscriptionChannelType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType> src) throws FHIRException { 114 if (src == null || src.isEmpty()) 115 return null; 116 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()); 117 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 118 switch (src.getValue()) { 119 case RESTHOOK: 120 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.RESTHOOK); 121 break; 122 case WEBSOCKET: 123 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.WEBSOCKET); 124 break; 125 case EMAIL: 126 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.EMAIL); 127 break; 128 case SMS: 129 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.SMS); 130 break; 131 case MESSAGE: 132 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.MESSAGE); 133 break; 134 default: 135 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType.NULL); 136 break; 137 } 138 return tgt; 139 } 140 141 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionStatus> convertSubscriptionStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus> src) throws FHIRException { 142 if (src == null || src.isEmpty()) 143 return null; 144 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()); 145 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 146 switch (src.getValue()) { 147 case REQUESTED: 148 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.REQUESTED); 149 break; 150 case ACTIVE: 151 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ACTIVE); 152 break; 153 case ERROR: 154 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.ERROR); 155 break; 156 case OFF: 157 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.OFF); 158 break; 159 default: 160 tgt.setValue(org.hl7.fhir.r4.model.Subscription.SubscriptionStatus.NULL); 161 break; 162 } 163 return tgt; 164 } 165 166 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus> convertSubscriptionStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Subscription.SubscriptionStatus> src) throws FHIRException { 167 if (src == null || src.isEmpty()) 168 return null; 169 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatusEnumFactory()); 170 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 171 switch (src.getValue()) { 172 case REQUESTED: 173 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.REQUESTED); 174 break; 175 case ACTIVE: 176 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.ACTIVE); 177 break; 178 case ERROR: 179 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.ERROR); 180 break; 181 case OFF: 182 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.OFF); 183 break; 184 default: 185 tgt.setValue(org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus.NULL); 186 break; 187 } 188 return tgt; 189 } 190}