
001package org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext14_50; 004import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.PositiveInt14_50; 005import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50; 006import org.hl7.fhir.exceptions.FHIRException; 007import org.hl7.fhir.r5.model.ContactPoint; 008 009public class ContactPoint14_50 { 010 public static org.hl7.fhir.r5.model.ContactPoint convertContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint src) throws FHIRException { 011 if (src == null || src.isEmpty()) return null; 012 org.hl7.fhir.r5.model.ContactPoint tgt = new org.hl7.fhir.r5.model.ContactPoint(); 013 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 014 if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); 015 if (src.hasValue()) tgt.setValueElement(String14_50.convertString(src.getValueElement())); 016 if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); 017 if (src.hasRank()) tgt.setRankElement(PositiveInt14_50.convertPositiveInt(src.getRankElement())); 018 if (src.hasPeriod()) tgt.setPeriod(Period14_50.convertPeriod(src.getPeriod())); 019 return tgt; 020 } 021 022 public static org.hl7.fhir.dstu2016may.model.ContactPoint convertContactPoint(org.hl7.fhir.r5.model.ContactPoint src) throws FHIRException { 023 if (src == null || src.isEmpty()) return null; 024 org.hl7.fhir.dstu2016may.model.ContactPoint tgt = new org.hl7.fhir.dstu2016may.model.ContactPoint(); 025 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 026 if (src.hasSystem()) tgt.setSystemElement(convertContactPointSystem(src.getSystemElement())); 027 if (src.hasValue()) tgt.setValueElement(String14_50.convertString(src.getValueElement())); 028 if (src.hasUse()) tgt.setUseElement(convertContactPointUse(src.getUseElement())); 029 if (src.hasRank()) tgt.setRankElement(PositiveInt14_50.convertPositiveInt(src.getRankElement())); 030 if (src.hasPeriod()) tgt.setPeriod(Period14_50.convertPeriod(src.getPeriod())); 031 return tgt; 032 } 033 034 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem> convertContactPointSystem(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem> src) throws FHIRException { 035 if (src == null || src.isEmpty()) return null; 036 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointSystemEnumFactory()); 037 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 038 if (src.getValue() == null) { 039 tgt.setValue(null); 040} else { 041 switch(src.getValue()) { 042 case PHONE: 043 tgt.setValue(ContactPoint.ContactPointSystem.PHONE); 044 break; 045 case FAX: 046 tgt.setValue(ContactPoint.ContactPointSystem.FAX); 047 break; 048 case EMAIL: 049 tgt.setValue(ContactPoint.ContactPointSystem.EMAIL); 050 break; 051 case PAGER: 052 tgt.setValue(ContactPoint.ContactPointSystem.PAGER); 053 break; 054 case OTHER: 055 tgt.setValue(ContactPoint.ContactPointSystem.URL); 056 break; 057 default: 058 tgt.setValue(ContactPoint.ContactPointSystem.NULL); 059 break; 060 } 061} 062 return tgt; 063 } 064 065 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem> convertContactPointSystem(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem> src) throws FHIRException { 066 if (src == null || src.isEmpty()) return null; 067 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystemEnumFactory()); 068 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 069 if (src.getValue() == null) { 070 tgt.setValue(null); 071} else { 072 switch(src.getValue()) { 073 case PHONE: 074 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PHONE); 075 break; 076 case FAX: 077 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.FAX); 078 break; 079 case EMAIL: 080 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.EMAIL); 081 break; 082 case PAGER: 083 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.PAGER); 084 break; 085 case URL: 086 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.OTHER); 087 break; 088 default: 089 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointSystem.NULL); 090 break; 091 } 092} 093 return tgt; 094 } 095 096 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ContactPoint.ContactPointUse> convertContactPointUse(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse> src) throws FHIRException { 097 if (src == null || src.isEmpty()) return null; 098 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ContactPoint.ContactPointUse> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ContactPoint.ContactPointUseEnumFactory()); 099 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 100 if (src.getValue() == null) { 101 tgt.setValue(null); 102} else { 103 switch(src.getValue()) { 104 case HOME: 105 tgt.setValue(ContactPoint.ContactPointUse.HOME); 106 break; 107 case WORK: 108 tgt.setValue(ContactPoint.ContactPointUse.WORK); 109 break; 110 case TEMP: 111 tgt.setValue(ContactPoint.ContactPointUse.TEMP); 112 break; 113 case OLD: 114 tgt.setValue(ContactPoint.ContactPointUse.OLD); 115 break; 116 case MOBILE: 117 tgt.setValue(ContactPoint.ContactPointUse.MOBILE); 118 break; 119 default: 120 tgt.setValue(ContactPoint.ContactPointUse.NULL); 121 break; 122 } 123} 124 return tgt; 125 } 126 127 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse> convertContactPointUse(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ContactPoint.ContactPointUse> src) throws FHIRException { 128 if (src == null || src.isEmpty()) return null; 129 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUseEnumFactory()); 130 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 131 if (src.getValue() == null) { 132 tgt.setValue(null); 133} else { 134 switch(src.getValue()) { 135 case HOME: 136 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.HOME); 137 break; 138 case WORK: 139 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.WORK); 140 break; 141 case TEMP: 142 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.TEMP); 143 break; 144 case OLD: 145 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.OLD); 146 break; 147 case MOBILE: 148 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.MOBILE); 149 break; 150 default: 151 tgt.setValue(org.hl7.fhir.dstu2016may.model.ContactPoint.ContactPointUse.NULL); 152 break; 153 } 154} 155 return tgt; 156 } 157}