001package org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
005import org.hl7.fhir.exceptions.FHIRException;
006import org.hl7.fhir.r5.model.Contributor;
007
008public class Contributor40_50 {
009  public static org.hl7.fhir.r5.model.Contributor convertContributor(org.hl7.fhir.r4.model.Contributor src) throws FHIRException {
010    if (src == null) return null;
011    org.hl7.fhir.r5.model.Contributor tgt = new org.hl7.fhir.r5.model.Contributor();
012    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
013    if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement()));
014    if (src.hasName()) tgt.setNameElement(String40_50.convertString(src.getNameElement()));
015    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
016      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
017    return tgt;
018  }
019
020  public static org.hl7.fhir.r4.model.Contributor convertContributor(org.hl7.fhir.r5.model.Contributor src) throws FHIRException {
021    if (src == null) return null;
022    org.hl7.fhir.r4.model.Contributor tgt = new org.hl7.fhir.r4.model.Contributor();
023    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
024    if (src.hasType()) tgt.setTypeElement(convertContributorType(src.getTypeElement()));
025    if (src.hasName()) tgt.setNameElement(String40_50.convertString(src.getNameElement()));
026    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
027      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
028    return tgt;
029  }
030
031  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Contributor.ContributorType> convertContributorType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Contributor.ContributorType> src) throws FHIRException {
032    if (src == null || src.isEmpty()) return null;
033    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Contributor.ContributorType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Contributor.ContributorTypeEnumFactory());
034    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
035    if (src.getValue() == null) {
036    tgt.setValue(null);
037} else {
038      switch(src.getValue()) {
039        case AUTHOR:
040                    tgt.setValue(Contributor.ContributorType.AUTHOR);
041                    break;
042                case EDITOR:
043                    tgt.setValue(Contributor.ContributorType.EDITOR);
044                    break;
045                case REVIEWER:
046                    tgt.setValue(Contributor.ContributorType.REVIEWER);
047                    break;
048                case ENDORSER:
049                    tgt.setValue(Contributor.ContributorType.ENDORSER);
050                    break;
051                default:
052                    tgt.setValue(Contributor.ContributorType.NULL);
053                    break;
054       }
055}
056    return tgt;
057  }
058
059  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Contributor.ContributorType> convertContributorType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Contributor.ContributorType> src) throws FHIRException {
060    if (src == null || src.isEmpty()) return null;
061    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Contributor.ContributorType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Contributor.ContributorTypeEnumFactory());
062    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
063    if (src.getValue() == null) {
064    tgt.setValue(null);
065} else {
066      switch(src.getValue()) {
067        case AUTHOR:
068                    tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.AUTHOR);
069                    break;
070                case EDITOR:
071                    tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.EDITOR);
072                    break;
073                case REVIEWER:
074                    tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.REVIEWER);
075                    break;
076                case ENDORSER:
077                    tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.ENDORSER);
078                    break;
079                default:
080                    tgt.setValue(org.hl7.fhir.r4.model.Contributor.ContributorType.NULL);
081                    break;
082       }
083}
084    return tgt;
085  }
086}