001package org.hl7.fhir.convertors.conv10_30.resources10_30;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_30;
004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30;
005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.*;
006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Boolean10_30;
007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class Organization10_30 {
011
012  public static org.hl7.fhir.dstu3.model.Organization convertOrganization(org.hl7.fhir.dstu2.model.Organization src) throws FHIRException {
013    if (src == null || src.isEmpty())
014      return null;
015    org.hl7.fhir.dstu3.model.Organization tgt = new org.hl7.fhir.dstu3.model.Organization();
016    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
017    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
018      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
019    if (src.hasActiveElement())
020      tgt.setActiveElement(Boolean10_30.convertBoolean(src.getActiveElement()));
021    if (src.hasType())
022      tgt.addType(CodeableConcept10_30.convertCodeableConcept(src.getType()));
023    if (src.hasNameElement())
024      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
025    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
026      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
027    for (org.hl7.fhir.dstu2.model.Address t : src.getAddress()) tgt.addAddress(Address10_30.convertAddress(t));
028    if (src.hasPartOf())
029      tgt.setPartOf(Reference10_30.convertReference(src.getPartOf()));
030    for (org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent t : src.getContact())
031      tgt.addContact(convertOrganizationContactComponent(t));
032    return tgt;
033  }
034
035  public static org.hl7.fhir.dstu2.model.Organization convertOrganization(org.hl7.fhir.dstu3.model.Organization src) throws FHIRException {
036    if (src == null || src.isEmpty())
037      return null;
038    org.hl7.fhir.dstu2.model.Organization tgt = new org.hl7.fhir.dstu2.model.Organization();
039    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
040    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
041      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
042    if (src.hasActiveElement())
043      tgt.setActiveElement(Boolean10_30.convertBoolean(src.getActiveElement()));
044    if (src.hasType())
045      tgt.setType(CodeableConcept10_30.convertCodeableConcept(src.getTypeFirstRep()));
046    if (src.hasNameElement())
047      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
048    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
049      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
050    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress()) tgt.addAddress(Address10_30.convertAddress(t));
051    if (src.hasPartOf())
052      tgt.setPartOf(Reference10_30.convertReference(src.getPartOf()));
053    for (org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent t : src.getContact())
054      tgt.addContact(convertOrganizationContactComponent(t));
055    return tgt;
056  }
057
058  public static org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent src) throws FHIRException {
059    if (src == null || src.isEmpty())
060      return null;
061    org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent();
062    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
063    if (src.hasPurpose())
064      tgt.setPurpose(CodeableConcept10_30.convertCodeableConcept(src.getPurpose()));
065    if (src.hasName())
066      tgt.setName(HumanName10_30.convertHumanName(src.getName()));
067    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
068      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
069    if (src.hasAddress())
070      tgt.setAddress(Address10_30.convertAddress(src.getAddress()));
071    return tgt;
072  }
073
074  public static org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent src) throws FHIRException {
075    if (src == null || src.isEmpty())
076      return null;
077    org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.dstu3.model.Organization.OrganizationContactComponent();
078    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
079    if (src.hasPurpose())
080      tgt.setPurpose(CodeableConcept10_30.convertCodeableConcept(src.getPurpose()));
081    if (src.hasName())
082      tgt.setName(HumanName10_30.convertHumanName(src.getName()));
083    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
084      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
085    if (src.hasAddress())
086      tgt.setAddress(Address10_30.convertAddress(src.getAddress()));
087    return tgt;
088  }
089}