
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.Reference10_40; 005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40; 006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40; 007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.DateTime10_40; 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class Communication10_40 { 011 012 public static org.hl7.fhir.r4.model.Communication convertCommunication(org.hl7.fhir.dstu2.model.Communication src) throws FHIRException { 013 if (src == null || src.isEmpty()) 014 return null; 015 org.hl7.fhir.r4.model.Communication tgt = new org.hl7.fhir.r4.model.Communication(); 016 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 017 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 018 tgt.addIdentifier(Identifier10_40.convertIdentifier(t)); 019 if (src.hasCategory()) 020 tgt.addCategory(CodeableConcept10_40.convertCodeableConcept(src.getCategory())); 021 if (src.hasSender()) 022 tgt.setSender(Reference10_40.convertReference(src.getSender())); 023 for (org.hl7.fhir.dstu2.model.Reference t : src.getRecipient()) 024 tgt.addRecipient(Reference10_40.convertReference(t)); 025 for (org.hl7.fhir.dstu2.model.Communication.CommunicationPayloadComponent t : src.getPayload()) 026 tgt.addPayload(convertCommunicationPayloadComponent(t)); 027 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getMedium()) 028 tgt.addMedium(CodeableConcept10_40.convertCodeableConcept(t)); 029 if (src.hasStatus()) 030 tgt.setStatusElement(convertCommunicationStatus(src.getStatusElement())); 031 if (src.hasEncounter()) 032 tgt.setEncounter(Reference10_40.convertReference(src.getEncounter())); 033 if (src.hasSentElement()) 034 tgt.setSentElement(DateTime10_40.convertDateTime(src.getSentElement())); 035 if (src.hasReceivedElement()) 036 tgt.setReceivedElement(DateTime10_40.convertDateTime(src.getReceivedElement())); 037 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getReason()) 038 tgt.addReasonCode(CodeableConcept10_40.convertCodeableConcept(t)); 039 if (src.hasSubject()) 040 tgt.setSubject(Reference10_40.convertReference(src.getSubject())); 041 return tgt; 042 } 043 044 public static org.hl7.fhir.dstu2.model.Communication convertCommunication(org.hl7.fhir.r4.model.Communication src) throws FHIRException { 045 if (src == null || src.isEmpty()) 046 return null; 047 org.hl7.fhir.dstu2.model.Communication tgt = new org.hl7.fhir.dstu2.model.Communication(); 048 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 049 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 050 tgt.addIdentifier(Identifier10_40.convertIdentifier(t)); 051 if (src.hasCategory()) 052 tgt.setCategory(CodeableConcept10_40.convertCodeableConcept(src.getCategoryFirstRep())); 053 if (src.hasSender()) 054 tgt.setSender(Reference10_40.convertReference(src.getSender())); 055 for (org.hl7.fhir.r4.model.Reference t : src.getRecipient()) tgt.addRecipient(Reference10_40.convertReference(t)); 056 for (org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent t : src.getPayload()) 057 tgt.addPayload(convertCommunicationPayloadComponent(t)); 058 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getMedium()) 059 tgt.addMedium(CodeableConcept10_40.convertCodeableConcept(t)); 060 if (src.hasStatus()) 061 tgt.setStatusElement(convertCommunicationStatus(src.getStatusElement())); 062 if (src.hasEncounter()) 063 tgt.setEncounter(Reference10_40.convertReference(src.getEncounter())); 064 if (src.hasSentElement()) 065 tgt.setSentElement(DateTime10_40.convertDateTime(src.getSentElement())); 066 if (src.hasReceivedElement()) 067 tgt.setReceivedElement(DateTime10_40.convertDateTime(src.getReceivedElement())); 068 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) 069 tgt.addReason(CodeableConcept10_40.convertCodeableConcept(t)); 070 if (src.hasSubject()) 071 tgt.setSubject(Reference10_40.convertReference(src.getSubject())); 072 return tgt; 073 } 074 075 public static org.hl7.fhir.dstu2.model.Communication.CommunicationPayloadComponent convertCommunicationPayloadComponent(org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent src) throws FHIRException { 076 if (src == null || src.isEmpty()) 077 return null; 078 org.hl7.fhir.dstu2.model.Communication.CommunicationPayloadComponent tgt = new org.hl7.fhir.dstu2.model.Communication.CommunicationPayloadComponent(); 079 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 080 if (src.hasContent()) 081 tgt.setContent(ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().convertType(src.getContent())); 082 return tgt; 083 } 084 085 public static org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent convertCommunicationPayloadComponent(org.hl7.fhir.dstu2.model.Communication.CommunicationPayloadComponent src) throws FHIRException { 086 if (src == null || src.isEmpty()) 087 return null; 088 org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent tgt = new org.hl7.fhir.r4.model.Communication.CommunicationPayloadComponent(); 089 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt); 090 if (src.hasContent()) 091 tgt.setContent(ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().convertType(src.getContent())); 092 return tgt; 093 } 094 095 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Communication.CommunicationStatus> convertCommunicationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Communication.CommunicationStatus> src) throws FHIRException { 096 if (src == null || src.isEmpty()) 097 return null; 098 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Communication.CommunicationStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Communication.CommunicationStatusEnumFactory()); 099 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 100 switch (src.getValue()) { 101 case INPROGRESS: 102 tgt.setValue(org.hl7.fhir.dstu2.model.Communication.CommunicationStatus.INPROGRESS); 103 break; 104 case COMPLETED: 105 tgt.setValue(org.hl7.fhir.dstu2.model.Communication.CommunicationStatus.COMPLETED); 106 break; 107 case ONHOLD: 108 tgt.setValue(org.hl7.fhir.dstu2.model.Communication.CommunicationStatus.SUSPENDED); 109 break; 110 case ENTEREDINERROR: 111 tgt.setValue(org.hl7.fhir.dstu2.model.Communication.CommunicationStatus.REJECTED); 112 break; 113 case NOTDONE: 114 tgt.setValue(org.hl7.fhir.dstu2.model.Communication.CommunicationStatus.FAILED); 115 break; 116 default: 117 tgt.setValue(org.hl7.fhir.dstu2.model.Communication.CommunicationStatus.NULL); 118 break; 119 } 120 return tgt; 121 } 122 123 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Communication.CommunicationStatus> convertCommunicationStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Communication.CommunicationStatus> src) throws FHIRException { 124 if (src == null || src.isEmpty()) 125 return null; 126 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Communication.CommunicationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Communication.CommunicationStatusEnumFactory()); 127 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 128 switch (src.getValue()) { 129 case INPROGRESS: 130 tgt.setValue(org.hl7.fhir.r4.model.Communication.CommunicationStatus.INPROGRESS); 131 break; 132 case COMPLETED: 133 tgt.setValue(org.hl7.fhir.r4.model.Communication.CommunicationStatus.COMPLETED); 134 break; 135 case SUSPENDED: 136 tgt.setValue(org.hl7.fhir.r4.model.Communication.CommunicationStatus.ONHOLD); 137 break; 138 case REJECTED: 139 tgt.setValue(org.hl7.fhir.r4.model.Communication.CommunicationStatus.ENTEREDINERROR); 140 break; 141 case FAILED: 142 tgt.setValue(org.hl7.fhir.r4.model.Communication.CommunicationStatus.NOTDONE); 143 break; 144 default: 145 tgt.setValue(org.hl7.fhir.r4.model.Communication.CommunicationStatus.NULL); 146 break; 147 } 148 return tgt; 149 } 150}