001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.DataRequirement30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ParameterDefinition30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.RelatedArtifact30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Attachment30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
012import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Period30_50;
013import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
014import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Date30_50;
015import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
016import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50;
017import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
018import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
019import org.hl7.fhir.dstu3.model.ContactDetail;
020import org.hl7.fhir.dstu3.model.Contributor.ContributorType;
021import org.hl7.fhir.exceptions.FHIRException;
022
023public class Library30_50 {
024
025  public static org.hl7.fhir.dstu3.model.Library convertLibrary(org.hl7.fhir.r5.model.Library src) throws FHIRException {
026    if (src == null)
027      return null;
028    org.hl7.fhir.dstu3.model.Library tgt = new org.hl7.fhir.dstu3.model.Library();
029    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
030    if (src.hasUrl())
031      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
032    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
033      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
034    if (src.hasVersion())
035      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
036    if (src.hasName())
037      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
038    if (src.hasTitle())
039      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
040    if (src.hasStatus())
041      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
042    if (src.hasExperimental())
043      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
044    if (src.hasType())
045      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
046    if (src.hasDate())
047      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
048    if (src.hasPublisher())
049      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
050    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
051      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
052    if (src.hasDescription())
053      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
054    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
055      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
056    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
057      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
058    if (src.hasPurpose())
059      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
060    if (src.hasUsage())
061      tgt.setUsageElement(String30_50.convertString(src.getUsageElement()));
062    if (src.hasCopyright())
063      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
064    if (src.hasApprovalDate())
065      tgt.setApprovalDateElement(Date30_50.convertDate(src.getApprovalDateElement()));
066    if (src.hasLastReviewDate())
067      tgt.setLastReviewDateElement(Date30_50.convertDate(src.getLastReviewDateElement()));
068    if (src.hasEffectivePeriod())
069      tgt.setEffectivePeriod(Period30_50.convertPeriod(src.getEffectivePeriod()));
070    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getTopic())
071      tgt.addTopic(CodeableConcept30_50.convertCodeableConcept(t));
072    for (org.hl7.fhir.r5.model.ContactDetail t : src.getAuthor()) {
073      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
074      c.setType(ContributorType.AUTHOR);
075      c.addContact(ContactDetail30_50.convertContactDetail(t));
076      tgt.addContributor(c);
077    }
078    for (org.hl7.fhir.r5.model.ContactDetail t : src.getEditor()) {
079      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
080      c.setType(ContributorType.EDITOR);
081      c.addContact(ContactDetail30_50.convertContactDetail(t));
082      tgt.addContributor(c);
083    }
084    for (org.hl7.fhir.r5.model.ContactDetail t : src.getReviewer()) {
085      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
086      c.setType(ContributorType.REVIEWER);
087      c.addContact(ContactDetail30_50.convertContactDetail(t));
088      tgt.addContributor(c);
089    }
090    for (org.hl7.fhir.r5.model.ContactDetail t : src.getEndorser()) {
091      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
092      c.setType(ContributorType.ENDORSER);
093      c.addContact(ContactDetail30_50.convertContactDetail(t));
094      tgt.addContributor(c);
095    }
096    for (org.hl7.fhir.r5.model.RelatedArtifact t : src.getRelatedArtifact())
097      tgt.addRelatedArtifact(RelatedArtifact30_50.convertRelatedArtifact(t));
098    for (org.hl7.fhir.r5.model.ParameterDefinition t : src.getParameter())
099      tgt.addParameter(ParameterDefinition30_50.convertParameterDefinition(t));
100    for (org.hl7.fhir.r5.model.DataRequirement t : src.getDataRequirement())
101      tgt.addDataRequirement(DataRequirement30_50.convertDataRequirement(t));
102    for (org.hl7.fhir.r5.model.Attachment t : src.getContent()) tgt.addContent(Attachment30_50.convertAttachment(t));
103    return tgt;
104  }
105
106  public static org.hl7.fhir.r5.model.Library convertLibrary(org.hl7.fhir.dstu3.model.Library src) throws FHIRException {
107    if (src == null)
108      return null;
109    org.hl7.fhir.r5.model.Library tgt = new org.hl7.fhir.r5.model.Library();
110    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
111    if (src.hasUrl())
112      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
113    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
114      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
115    if (src.hasVersion())
116      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
117    if (src.hasName())
118      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
119    if (src.hasTitle())
120      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
121    if (src.hasStatus())
122      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
123    if (src.hasExperimental())
124      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
125    if (src.hasType())
126      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
127    if (src.hasDate())
128      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
129    if (src.hasPublisher())
130      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
131    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
132      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
133    if (src.hasDescription())
134      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
135    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
136      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
137    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
138      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
139    if (src.hasPurpose())
140      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
141    if (src.hasUsage())
142      tgt.setUsageElement(String30_50.convertStringToMarkdown(src.getUsageElement()));
143    if (src.hasCopyright())
144      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
145    if (src.hasApprovalDate())
146      tgt.setApprovalDateElement(Date30_50.convertDate(src.getApprovalDateElement()));
147    if (src.hasLastReviewDate())
148      tgt.setLastReviewDateElement(Date30_50.convertDate(src.getLastReviewDateElement()));
149    if (src.hasEffectivePeriod())
150      tgt.setEffectivePeriod(Period30_50.convertPeriod(src.getEffectivePeriod()));
151    for (org.hl7.fhir.dstu3.model.Contributor t : src.getContributor()) {
152      if (t.getType() == ContributorType.AUTHOR)
153        for (ContactDetail c : t.getContact()) tgt.addAuthor(ContactDetail30_50.convertContactDetail(c));
154      if (t.getType() == ContributorType.EDITOR)
155        for (ContactDetail c : t.getContact()) tgt.addEditor(ContactDetail30_50.convertContactDetail(c));
156      if (t.getType() == ContributorType.REVIEWER)
157        for (ContactDetail c : t.getContact()) tgt.addReviewer(ContactDetail30_50.convertContactDetail(c));
158      if (t.getType() == ContributorType.ENDORSER)
159        for (ContactDetail c : t.getContact()) tgt.addEndorser(ContactDetail30_50.convertContactDetail(c));
160    }
161    for (org.hl7.fhir.dstu3.model.RelatedArtifact t : src.getRelatedArtifact())
162      tgt.addRelatedArtifact(RelatedArtifact30_50.convertRelatedArtifact(t));
163    for (org.hl7.fhir.dstu3.model.ParameterDefinition t : src.getParameter())
164      tgt.addParameter(ParameterDefinition30_50.convertParameterDefinition(t));
165    for (org.hl7.fhir.dstu3.model.DataRequirement t : src.getDataRequirement())
166      tgt.addDataRequirement(DataRequirement30_50.convertDataRequirement(t));
167    for (org.hl7.fhir.dstu3.model.Attachment t : src.getContent()) tgt.addContent(Attachment30_50.convertAttachment(t));
168    return tgt;
169  }
170}