Add provenance support for version conversion. + add Provenance rendering

This commit is contained in:
Grahame Grieve 2020-05-01 11:14:29 +10:00
parent bc21de6d78
commit c003f1fca4
8 changed files with 646 additions and 45 deletions

View File

@ -65,6 +65,7 @@ import org.hl7.fhir.convertors.conv10_50.Parameters10_50;
import org.hl7.fhir.convertors.conv10_50.Patient10_50; import org.hl7.fhir.convertors.conv10_50.Patient10_50;
import org.hl7.fhir.convertors.conv10_50.Person10_50; import org.hl7.fhir.convertors.conv10_50.Person10_50;
import org.hl7.fhir.convertors.conv10_50.Practitioner10_50; import org.hl7.fhir.convertors.conv10_50.Practitioner10_50;
import org.hl7.fhir.convertors.conv10_50.Provenance10_50;
import org.hl7.fhir.convertors.conv10_50.Questionnaire10_50; import org.hl7.fhir.convertors.conv10_50.Questionnaire10_50;
import org.hl7.fhir.convertors.conv10_50.QuestionnaireResponse10_50; import org.hl7.fhir.convertors.conv10_50.QuestionnaireResponse10_50;
import org.hl7.fhir.convertors.conv10_50.RiskAssessment10_50; import org.hl7.fhir.convertors.conv10_50.RiskAssessment10_50;
@ -3307,7 +3308,9 @@ public class VersionConvertor_10_50 {
if (src instanceof org.hl7.fhir.dstu2.model.Person) if (src instanceof org.hl7.fhir.dstu2.model.Person)
return Person10_50.convertPerson((org.hl7.fhir.dstu2.model.Person) src); return Person10_50.convertPerson((org.hl7.fhir.dstu2.model.Person) src);
if (src instanceof org.hl7.fhir.dstu2.model.Practitioner) if (src instanceof org.hl7.fhir.dstu2.model.Practitioner)
return Practitioner10_50.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src); return Practitioner10_50.convertPractitioner((org.hl7.fhir.dstu2.model.Practitioner) src);
if (src instanceof org.hl7.fhir.dstu2.model.Provenance)
return Provenance10_50.convertProvenance((org.hl7.fhir.dstu2.model.Provenance) src);
if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire) if (src instanceof org.hl7.fhir.dstu2.model.Questionnaire)
return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src); return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.dstu2.model.Questionnaire) src);
if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse) if (src instanceof org.hl7.fhir.dstu2.model.QuestionnaireResponse)
@ -3420,6 +3423,8 @@ public class VersionConvertor_10_50 {
return Person10_50.convertPerson((org.hl7.fhir.r5.model.Person) src); return Person10_50.convertPerson((org.hl7.fhir.r5.model.Person) src);
if (src instanceof org.hl7.fhir.r5.model.Practitioner) if (src instanceof org.hl7.fhir.r5.model.Practitioner)
return Practitioner10_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); return Practitioner10_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src);
if (src instanceof org.hl7.fhir.r5.model.Provenance)
return Provenance10_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src);
if (src instanceof org.hl7.fhir.r5.model.Questionnaire) if (src instanceof org.hl7.fhir.r5.model.Questionnaire)
return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); return Questionnaire10_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src);
if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse)

View File

@ -85,6 +85,7 @@ import org.hl7.fhir.convertors.conv30_50.Person30_50;
import org.hl7.fhir.convertors.conv30_50.PlanDefinition30_50; import org.hl7.fhir.convertors.conv30_50.PlanDefinition30_50;
import org.hl7.fhir.convertors.conv30_50.Practitioner30_50; import org.hl7.fhir.convertors.conv30_50.Practitioner30_50;
import org.hl7.fhir.convertors.conv30_50.PractitionerRole30_50; import org.hl7.fhir.convertors.conv30_50.PractitionerRole30_50;
import org.hl7.fhir.convertors.conv30_50.Provenance30_50;
import org.hl7.fhir.convertors.conv30_50.Questionnaire30_50; import org.hl7.fhir.convertors.conv30_50.Questionnaire30_50;
import org.hl7.fhir.convertors.conv30_50.QuestionnaireResponse30_50; import org.hl7.fhir.convertors.conv30_50.QuestionnaireResponse30_50;
import org.hl7.fhir.convertors.conv30_50.RelatedPerson30_50; import org.hl7.fhir.convertors.conv30_50.RelatedPerson30_50;
@ -5324,6 +5325,8 @@ public class VersionConvertor_30_50 {
return Practitioner30_50.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src); return Practitioner30_50.convertPractitioner((org.hl7.fhir.dstu3.model.Practitioner) src);
if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole) if (src instanceof org.hl7.fhir.dstu3.model.PractitionerRole)
return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src); return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.dstu3.model.PractitionerRole) src);
if (src instanceof org.hl7.fhir.dstu3.model.Provenance)
return Provenance30_50.convertProvenance((org.hl7.fhir.dstu3.model.Provenance) src);
if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire) if (src instanceof org.hl7.fhir.dstu3.model.Questionnaire)
return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src); return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.dstu3.model.Questionnaire) src);
if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse) if (src instanceof org.hl7.fhir.dstu3.model.QuestionnaireResponse)
@ -5491,6 +5494,8 @@ public class VersionConvertor_30_50 {
return Practitioner30_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src); return Practitioner30_50.convertPractitioner((org.hl7.fhir.r5.model.Practitioner) src);
if (src instanceof org.hl7.fhir.r5.model.PractitionerRole) if (src instanceof org.hl7.fhir.r5.model.PractitionerRole)
return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src); return PractitionerRole30_50.convertPractitionerRole((org.hl7.fhir.r5.model.PractitionerRole) src);
if (src instanceof org.hl7.fhir.r5.model.Provenance)
return Provenance30_50.convertProvenance((org.hl7.fhir.r5.model.Provenance) src);
if (src instanceof org.hl7.fhir.r5.model.Questionnaire) if (src instanceof org.hl7.fhir.r5.model.Questionnaire)
return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src); return Questionnaire30_50.convertQuestionnaire((org.hl7.fhir.r5.model.Questionnaire) src);
if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse) if (src instanceof org.hl7.fhir.r5.model.QuestionnaireResponse)

View File

@ -0,0 +1,208 @@
package org.hl7.fhir.convertors.conv10_50;
/*-
* #%L
* org.hl7.fhir.convertors
* %%
* Copyright (C) 2014 - 2019 Health Level 7
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.hl7.fhir.convertors.VersionConvertor_10_50;
import org.hl7.fhir.dstu2.model.Period;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
public class Provenance10_50 extends VersionConvertor_10_50 {
public static org.hl7.fhir.r5.model.Provenance convertProvenance(org.hl7.fhir.dstu2.model.Provenance src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Provenance tgt = new org.hl7.fhir.r5.model.Provenance();
copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu2.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t));
if (src.hasPeriod())
tgt.setOccurred(convertType(src.getPeriod()));
if (src.hasRecorded())
tgt.setRecordedElement(convertInstant(src.getRecordedElement()));
for (org.hl7.fhir.dstu2.model.UriType t : src.getPolicy()) tgt.getPolicy().add(convertUri(t));
if (src.hasLocation())
tgt.setLocation(convertReference(src.getLocation()));
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getReason())
tgt.addReason(convertCodeableConcept(t));
if (src.hasActivity())
tgt.setActivity(convertCodeableConcept(src.getActivity()));
for (org.hl7.fhir.dstu2.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t));
for (org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) tgt.addEntity(convertProvenanceEntityComponent(t));
for (org.hl7.fhir.dstu2.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t));
return tgt;
}
public static org.hl7.fhir.dstu2.model.Provenance convertProvenance(org.hl7.fhir.r5.model.Provenance src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu2.model.Provenance tgt = new org.hl7.fhir.dstu2.model.Provenance();
copyDomainResource(src, tgt);
for (org.hl7.fhir.r5.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t));
if (src.hasOccurredPeriod())
tgt.setPeriod(convertPeriod(src.getOccurredPeriod()));
if (src.hasRecorded())
tgt.setRecordedElement(convertInstant(src.getRecordedElement()));
for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.getPolicy().add(convertUri(t));
if (src.hasLocation())
tgt.setLocation(convertReference(src.getLocation()));
for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReason())
tgt.addReason(convertCodeableConcept(t));
if (src.hasActivity())
tgt.setActivity(convertCodeableConcept(src.getActivity()));
for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t));
for (org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) tgt.addEntity(convertProvenanceEntityComponent(t));
for (org.hl7.fhir.r5.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t));
return tgt;
}
public static org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.dstu2.model.Provenance.ProvenanceAgentComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent();
copyElement(src, tgt);
// if (src.hasType())
// tgt.setType(convertCodeableConcept(src.getType()));
if (src.hasRole())
tgt.getRoleFirstRep().addCoding(convertCoding(src.getRole()));
if (src.hasActor())
tgt.setWho(convertReference(src.getActor()));
return tgt;
}
public static org.hl7.fhir.dstu2.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu2.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.dstu2.model.Provenance.ProvenanceAgentComponent();
copyElement(src, tgt);
// if (src.hasType())
// tgt.setType(convertCodeableConcept(src.getType()));
for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole())
for (org.hl7.fhir.r5.model.Coding t2 : t.getCoding())
tgt.setRole(convertCoding(t2));
if (src.hasWho())
tgt.setActor(convertReference(src.getWho()));
return tgt;
}
public static org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent();
copyElement(src, tgt);
if (src.hasRole())
tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement()));
if (src.hasReference())
tgt.getWhat().setReference(src.getReference());
tgt.addAgent(convertProvenanceAgentComponent(src.getAgent()));
return tgt;
}
public static org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityComponent();
copyElement(src, tgt);
if (src.hasRole())
tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement()));
if (Utilities.isAbsoluteUrl(src.getWhat().getReference()))
tgt.setReference(src.getWhat().getReference());
for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.setAgent(convertProvenanceAgentComponent(t));
return tgt;
}
static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> convertProvenanceEntityRole(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRoleEnumFactory());
VersionConvertor_10_50.copyElement(src, tgt);
switch(src.getValue()) {
case DERIVATION:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.DERIVATION);
break;
case REVISION:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REVISION);
break;
case QUOTATION:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.QUOTATION);
break;
case SOURCE:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.SOURCE);
break;
default:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole> convertProvenanceEntityRole(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRoleEnumFactory());
VersionConvertor_10_50.copyElement(src, tgt);
switch(src.getValue()) {
case DERIVATION:
tgt.setValue(org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole.DERIVATION);
break;
case REVISION:
tgt.setValue(org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole.REVISION);
break;
case QUOTATION:
tgt.setValue(org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole.QUOTATION);
break;
case SOURCE:
tgt.setValue(org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole.SOURCE);
break;
default:
tgt.setValue(org.hl7.fhir.dstu2.model.Provenance.ProvenanceEntityRole.NULL);
break;
}
return tgt;
}
}

View File

@ -0,0 +1,216 @@
package org.hl7.fhir.convertors.conv30_50;
/*-
* #%L
* org.hl7.fhir.convertors
* %%
* Copyright (C) 2014 - 2019 Health Level 7
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.hl7.fhir.convertors.VersionConvertor_30_50;
import org.hl7.fhir.dstu3.model.Period;
import org.hl7.fhir.exceptions.FHIRException;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
public class Provenance30_50 extends VersionConvertor_30_50 {
public static org.hl7.fhir.r5.model.Provenance convertProvenance(org.hl7.fhir.dstu3.model.Provenance src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Provenance tgt = new org.hl7.fhir.r5.model.Provenance();
copyDomainResource(src, tgt);
for (org.hl7.fhir.dstu3.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t));
if (src.hasPeriod())
tgt.setOccurred(convertType(src.getPeriod()));
if (src.hasRecorded())
tgt.setRecordedElement(convertInstant(src.getRecordedElement()));
for (org.hl7.fhir.dstu3.model.UriType t : src.getPolicy()) tgt.getPolicy().add(convertUri(t));
if (src.hasLocation())
tgt.setLocation(convertReference(src.getLocation()));
for (org.hl7.fhir.dstu3.model.Coding t : src.getReason())
tgt.addReason().addCoding(convertCoding(t));
if (src.hasActivity())
tgt.getActivity().addCoding(convertCoding(src.getActivity()));
for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t));
for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) tgt.addEntity(convertProvenanceEntityComponent(t));
for (org.hl7.fhir.dstu3.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t));
return tgt;
}
public static org.hl7.fhir.dstu3.model.Provenance convertProvenance(org.hl7.fhir.r5.model.Provenance src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.Provenance tgt = new org.hl7.fhir.dstu3.model.Provenance();
copyDomainResource(src, tgt);
for (org.hl7.fhir.r5.model.Reference t : src.getTarget()) tgt.addTarget(convertReference(t));
if (src.hasOccurredPeriod())
tgt.setPeriod(convertPeriod(src.getOccurredPeriod()));
if (src.hasRecorded())
tgt.setRecordedElement(convertInstant(src.getRecordedElement()));
for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.getPolicy().add(convertUri(t));
if (src.hasLocation())
tgt.setLocation(convertReference(src.getLocation()));
for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReason())
for (org.hl7.fhir.r5.model.Coding t2 : t.getCoding())
tgt.addReason(convertCoding(t2));
if (src.hasActivity())
tgt.setActivity(convertCoding(src.getActivity().getCodingFirstRep()));
for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t));
for (org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) tgt.addEntity(convertProvenanceEntityComponent(t));
for (org.hl7.fhir.r5.model.Signature t : src.getSignature()) tgt.addSignature(convertSignature(t));
return tgt;
}
public static org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent();
copyElement(src, tgt);
// if (src.hasType())
// tgt.setType(convertCodeableConcept(src.getType()));
for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole())
tgt.addRole(convertCodeableConcept(t));
if (src.hasWhoReference())
tgt.setWho(convertReference(src.getWhoReference()));
if (src.hasOnBehalfOfReference())
tgt.setOnBehalfOf(convertReference(src.getOnBehalfOfReference()));
return tgt;
}
public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent();
copyElement(src, tgt);
// if (src.hasType())
// tgt.setType(convertCodeableConcept(src.getType()));
for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t));
if (src.hasWho())
tgt.setWho(convertReference(src.getWho()));
if (src.hasOnBehalfOf())
tgt.setOnBehalfOf(convertReference(src.getOnBehalfOf()));
return tgt;
}
public static org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent();
copyElement(src, tgt);
if (src.hasRole())
tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement()));
if (src.hasWhatReference())
tgt.setWhat(convertReference(src.getWhatReference()));
for (org.hl7.fhir.dstu3.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t));
return tgt;
}
public static org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityComponent();
copyElement(src, tgt);
if (src.hasRole())
tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement()));
if (src.hasWhat())
tgt.setWhat(convertReference(src.getWhat()));
for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) tgt.addAgent(convertProvenanceAgentComponent(t));
return tgt;
}
static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> convertProvenanceEntityRole(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRoleEnumFactory());
VersionConvertor_30_50.copyElement(src, tgt);
switch(src.getValue()) {
case DERIVATION:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.DERIVATION);
break;
case REVISION:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REVISION);
break;
case QUOTATION:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.QUOTATION);
break;
case SOURCE:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.SOURCE);
break;
case REMOVAL:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.REMOVAL);
break;
default:
tgt.setValue(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole.NULL);
break;
}
return tgt;
}
static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole> convertProvenanceEntityRole(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRoleEnumFactory());
VersionConvertor_30_50.copyElement(src, tgt);
switch(src.getValue()) {
case DERIVATION:
tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.DERIVATION);
break;
case REVISION:
tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REVISION);
break;
case QUOTATION:
tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.QUOTATION);
break;
case SOURCE:
tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.SOURCE);
break;
case REMOVAL:
tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.REMOVAL);
break;
default:
tgt.setValue(org.hl7.fhir.dstu3.model.Provenance.ProvenanceEntityRole.NULL);
break;
}
return tgt;
}
}

View File

@ -38,7 +38,6 @@ public class VersionConvertorPrimitiveType10_50Test {
Assertions.assertEquals(ae5.getId(), ae2.getId()); Assertions.assertEquals(ae5.getId(), ae2.getId());
} }
@ParameterizedTest(name = "Testing dstu2 -> r5 conversion of null value {0}.") @ParameterizedTest(name = "Testing dstu2 -> r5 conversion of null value {0}.")
@MethodSource("dstu2PrimitiveTypes") @MethodSource("dstu2PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) { public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {

View File

@ -30,13 +30,22 @@ import java.util.stream.Stream;
public class VersionConvertorPrimitiveType30_50Test { public class VersionConvertorPrimitiveType30_50Test {
private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"type\" : {\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"recorded\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\",\"agent\" : [{\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"userId\" : {\"value\" : \"Grahame\"},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}},{\"role\" : [{\"coding\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110153\",\"display\" : \"Source Role ID\"}]}],\"userId\" : {\"value\" : \"2.16.840.1.113883.4.2|2.16.840.1.113883.4.2\"},\"altId\" : \"6580\",\"requestor\" : false,\"network\" : {\"address\" : \"Workstation1.ehr.familyclinic.com\",\"type\" : \"1\"}}],\"source\" : {\"site\" : \"Development\",\"identifier\" : {\"value\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110122\",\"display\" : \"Login\"}]},\"entity\" : [{\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://hl7.org/fhir/identifier-type\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"},\"type\" : {\"system\" : \"http://hl7.org/fhir/object-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://hl7.org/fhir/object-role\",\"code\" : \"4\",\"display\" : \"Domain Resource\"},\"lifecycle\" : {\"system\" : \"http://hl7.org/fhir/dicom-audit-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}"; private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"type\" : {\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"recorded\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\",\"agent\" : [{\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"userId\" : {\"value\" : \"Grahame\"},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}},{\"role\" : [{\"coding\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110153\",\"display\" : \"Source Role ID\"}]}],\"userId\" : {\"value\" : \"2.16.840.1.113883.4.2|2.16.840.1.113883.4.2\"},\"altId\" : \"6580\",\"requestor\" : false,\"network\" : {\"address\" : \"Workstation1.ehr.familyclinic.com\",\"type\" : \"1\"}}],\"source\" : {\"site\" : \"Development\",\"identifier\" : {\"value\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110122\",\"display\" : \"Login\"}]},\"entity\" : [{\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://hl7.org/fhir/identifier-type\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"},\"type\" : {\"system\" : \"http://hl7.org/fhir/object-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://hl7.org/fhir/object-role\",\"code\" : \"4\",\"display\" : \"Domain Resource\"},\"lifecycle\" : {\"system\" : \"http://hl7.org/fhir/dicom-audit-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}";
private static final String PROVENANCE_SOURCE = "{\"resourceType\" : \"Provenance\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">procedure record authored on 27-June 2015 by Harold Hippocrates, MD Content extracted from XDS managed CDA Referral received 26-June</div>\"},\"target\" : [{\"reference\" : \"Procedure/example/_history/1\"}],\"period\" : {\"start\" : \"2015-06-27\",\"end\" : \"2015-06-28\"},\"recorded\" : \"2015-06-27T08:39:24+10:00\",\"policy\" : [\"http://acme.com/fhir/Consent/25\"],\"location\" : {\"reference\" : \"Location/1\"},\"reason\" : [{\"system\" : \"http://snomed.info/sct\",\"code\" : \"3457005\",\"display\" : \"Referral\"}],\"agent\" : [{\"role\" : [{\"coding\" : [{\"system\" : \"http://hl7.org/fhir/v3/ParticipationType\",\"code\" : \"AUT\"}]}],\"whoReference\" : {\"reference\" : \"Practitioner/xcda-author\"},\"onBehalfOfUri\" : \"#a1\",\"relatedAgentType\" : {\"text\" : \"used\"}},{\"id\" : \"a1\",\"role\" : [{\"coding\" : [{\"system\" : \"http://hl7.org/fhir/v3/ParticipationType\",\"code\" : \"DEV\"}]}],\"whoReference\" : {\"reference\" : \"Device/software\"}}],\"entity\" : [{\"role\" : \"source\",\"whatReference\" : {\"reference\" : \"DocumentReference/example\",\"display\" : \"CDA Document in XDS repository\"}}]}";
@Test @Test
public void testAuditEvent() throws FHIRFormatError, IOException { public void testAuditEvent() throws FHIRFormatError, IOException {
org.hl7.fhir.dstu3.model.AuditEvent ae3 = (org.hl7.fhir.dstu3.model.AuditEvent) new org.hl7.fhir.dstu3.formats.JsonParser().parse(AUDIT_EVENT_SOURCE); org.hl7.fhir.dstu3.model.AuditEvent ae3 = (org.hl7.fhir.dstu3.model.AuditEvent) new org.hl7.fhir.dstu3.formats.JsonParser().parse(AUDIT_EVENT_SOURCE);
org.hl7.fhir.r5.model.AuditEvent ae5 = (org.hl7.fhir.r5.model.AuditEvent) VersionConvertor_30_50.convertResource(ae3, false); org.hl7.fhir.r5.model.AuditEvent ae5 = (org.hl7.fhir.r5.model.AuditEvent) VersionConvertor_30_50.convertResource(ae3, false);
Assertions.assertEquals(ae5.getId(), ae3.getId()); Assertions.assertEquals(ae5.getId(), ae3.getId());
} }
@Test
public void testProvenance() throws FHIRFormatError, IOException {
org.hl7.fhir.dstu3.model.Provenance ae3 = (org.hl7.fhir.dstu3.model.Provenance) new org.hl7.fhir.dstu3.formats.JsonParser().parse(PROVENANCE_SOURCE);
org.hl7.fhir.r5.model.Provenance ae5 = (org.hl7.fhir.r5.model.Provenance) VersionConvertor_30_50.convertResource(ae3, false);
Assertions.assertEquals(ae5.getId(), ae3.getId());
}
@ParameterizedTest(name = "Testing dstu3 -> r5 conversion of null value {0}.") @ParameterizedTest(name = "Testing dstu3 -> r5 conversion of null value {0}.")
@MethodSource("dstu3PrimitiveTypes") @MethodSource("dstu3PrimitiveTypes")

View File

@ -30,6 +30,7 @@ import java.util.stream.Stream;
public class VersionConvertorPrimitiveType40_50Test { public class VersionConvertorPrimitiveType40_50Test {
private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"type\" : {\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"recorded\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\",\"agent\" : [{\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/extra-security-role-type\",\"code\" : \"humanuser\",\"display\" : \"human user\"}]},\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"who\" : {\"identifier\" : {\"value\" : \"Grahame\"}},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}},{\"type\" : {\"coding\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110153\",\"display\" : \"Source Role ID\"}]},\"who\" : {\"identifier\" : {\"system\" : \"urn:oid:2.16.840.1.113883.4.2\",\"value\" : \"2.16.840.1.113883.4.2\"}},\"altId\" : \"6580\",\"requestor\" : false,\"network\" : {\"address\" : \"Workstation1.ehr.familyclinic.com\",\"type\" : \"1\"}}],\"source\" : {\"site\" : \"Development\",\"observer\" : {\"display\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110122\",\"display\" : \"Login\"}]},\"entity\" : [{\"what\" : {\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/v2-0203\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"}},\"type\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/audit-entity-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/object-role\",\"code\" : \"4\",\"display\" : \"Domain Resource\"},\"lifecycle\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}"; private static final String AUDIT_EVENT_SOURCE = "{\"resourceType\" : \"AuditEvent\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">Application Start for under service login &quot;Grahame&quot; (id: Grahame's Test HL7Connect)</div>\"},\"type\" : {\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110100\",\"display\" : \"Application Activity\"},\"subtype\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110120\",\"display\" : \"Application Start\"}],\"action\" : \"E\",\"recorded\" : \"2012-10-25T22:04:27+11:00\",\"outcome\" : \"0\",\"agent\" : [{\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/extra-security-role-type\",\"code\" : \"humanuser\",\"display\" : \"human user\"}]},\"role\" : [{\"text\" : \"Service User (Logon)\"}],\"who\" : {\"identifier\" : {\"value\" : \"Grahame\"}},\"requestor\" : false,\"network\" : {\"address\" : \"127.0.0.1\",\"type\" : \"2\"}},{\"type\" : {\"coding\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110153\",\"display\" : \"Source Role ID\"}]},\"who\" : {\"identifier\" : {\"system\" : \"urn:oid:2.16.840.1.113883.4.2\",\"value\" : \"2.16.840.1.113883.4.2\"}},\"altId\" : \"6580\",\"requestor\" : false,\"network\" : {\"address\" : \"Workstation1.ehr.familyclinic.com\",\"type\" : \"1\"}}],\"source\" : {\"site\" : \"Development\",\"observer\" : {\"display\" : \"Grahame's Laptop\"},\"type\" : [{\"system\" : \"http://dicom.nema.org/resources/ontology/DCM\",\"code\" : \"110122\",\"display\" : \"Login\"}]},\"entity\" : [{\"what\" : {\"identifier\" : {\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/v2-0203\",\"code\" : \"SNO\"}],\"text\" : \"Dell Serial Number\"},\"value\" : \"ABCDEF\"}},\"type\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/audit-entity-type\",\"code\" : \"4\",\"display\" : \"Other\"},\"role\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/object-role\",\"code\" : \"4\",\"display\" : \"Domain Resource\"},\"lifecycle\" : {\"system\" : \"http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle\",\"code\" : \"6\",\"display\" : \"Access / Use\"},\"name\" : \"Grahame's Laptop\"}]}";
private static final String PROVENANCE_SOURCE = "{\"resourceType\" : \"Provenance\",\"id\" : \"example\",\"text\" : {\"status\" : \"generated\",\"div\" : \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">procedure record authored on 27-June 2015 by Harold Hippocrates, MD Content extracted from XDS managed CDA Referral received 26-June as authorized by a referenced Consent.</div>\"},\"target\" : [{\"reference\" : \"Procedure/example/_history/1\"}],\"occurredPeriod\" : {\"start\" : \"2015-06-27\",\"end\" : \"2015-06-28\"},\"recorded\" : \"2015-06-27T08:39:24+10:00\",\"policy\" : [\"http://acme.com/fhir/Consent/25\"],\"location\" : {\"reference\" : \"Location/1\"},\"reason\" : [{\"coding\" : [{\"system\" : \"http://snomed.info/sct\",\"code\" : \"3457005\",\"display\" : \"Referral\"}]}],\"agent\" : [{\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/v3-ParticipationType\",\"code\" : \"AUT\"}]},\"who\" : {\"reference\" : \"Practitioner/xcda-author\"}},{\"id\" : \"a1\",\"type\" : {\"coding\" : [{\"system\" : \"http://terminology.hl7.org/CodeSystem/v3-ParticipationType\",\"code\" : \"DEV\"}]},\"who\" : {\"reference\" : \"Device/software\"}}],\"entity\" : [{\"role\" : \"source\",\"what\" : {\"reference\" : \"DocumentReference/example\",\"display\" : \"CDA Document in XDS repository\"}}]}";
@Test @Test
public void testAuditEvent() throws FHIRFormatError, IOException { public void testAuditEvent() throws FHIRFormatError, IOException {
@ -39,6 +40,14 @@ public class VersionConvertorPrimitiveType40_50Test {
} }
@Test
public void testProvenance() throws FHIRFormatError, IOException {
org.hl7.fhir.r4.model.Provenance ae4 = (org.hl7.fhir.r4.model.Provenance) new org.hl7.fhir.r4.formats.JsonParser().parse(PROVENANCE_SOURCE);
org.hl7.fhir.r5.model.Provenance ae5 = (org.hl7.fhir.r5.model.Provenance) VersionConvertor_40_50.convertResource(ae4);
Assertions.assertEquals(ae5.getId(), ae4.getId());
}
@ParameterizedTest(name = "Testing r4 -> r5 conversion of null value {0}.") @ParameterizedTest(name = "Testing r4 -> r5 conversion of null value {0}.")
@MethodSource("r4PrimitiveTypes") @MethodSource("r4PrimitiveTypes")
public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) { public <T extends PrimitiveType> void testNullValueDstu2Primitive(String classname, T obj) {

View File

@ -156,6 +156,8 @@ import org.hl7.fhir.r5.model.Patient;
import org.hl7.fhir.r5.model.Period; import org.hl7.fhir.r5.model.Period;
import org.hl7.fhir.r5.model.PrimitiveType; import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.Property; import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Provenance;
import org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent;
import org.hl7.fhir.r5.model.Quantity; import org.hl7.fhir.r5.model.Quantity;
import org.hl7.fhir.r5.model.Questionnaire; import org.hl7.fhir.r5.model.Questionnaire;
import org.hl7.fhir.r5.model.Range; import org.hl7.fhir.r5.model.Range;
@ -335,25 +337,27 @@ public class NarrativeGenerator implements INarrativeGenerator {
} }
} }
if (r instanceof ConceptMap) { if (r instanceof ConceptMap) {
return generate(rcontext, (ConceptMap) r); // Maintainer = Grahame return generate(rcontext, (ConceptMap) r);
} else if (r instanceof ValueSet) { } else if (r instanceof ValueSet) {
return generate(rcontext, (ValueSet) r, true); // Maintainer = Grahame return generate(rcontext, (ValueSet) r, true);
} else if (r instanceof CodeSystem) { } else if (r instanceof CodeSystem) {
return generate(rcontext, (CodeSystem) r, true, null); // Maintainer = Grahame return generate(rcontext, (CodeSystem) r, true, null);
} else if (r instanceof OperationOutcome) { } else if (r instanceof OperationOutcome) {
return generate(rcontext, (OperationOutcome) r); // Maintainer = Grahame return generate(rcontext, (OperationOutcome) r);
} else if (r instanceof CapabilityStatement) { } else if (r instanceof CapabilityStatement) {
return generate(rcontext, (CapabilityStatement) r); // Maintainer = Grahame return generate(rcontext, (CapabilityStatement) r);
} else if (r instanceof CompartmentDefinition) { } else if (r instanceof CompartmentDefinition) {
return generate(rcontext, (CompartmentDefinition) r); // Maintainer = Grahame return generate(rcontext, (CompartmentDefinition) r);
} else if (r instanceof OperationDefinition) { } else if (r instanceof OperationDefinition) {
return generate(rcontext, (OperationDefinition) r); // Maintainer = Grahame return generate(rcontext, (OperationDefinition) r);
} else if (r instanceof StructureDefinition) { } else if (r instanceof StructureDefinition) {
return generate(rcontext, (StructureDefinition) r, outputTracker); // Maintainer = Grahame return generate(rcontext, (StructureDefinition) r, outputTracker);
} else if (r instanceof List) { } else if (r instanceof List) {
return generate(rcontext, (ListResource) r); // Maintainer = Grahame return generate(rcontext, (ListResource) r);
} else if (r instanceof ImplementationGuide) { } else if (r instanceof ImplementationGuide) {
return generate(rcontext, (ImplementationGuide) r); // Maintainer = Lloyd (until Grahame wants to take over . . . :)) return generate(rcontext, (ImplementationGuide) r);
} else if (r instanceof Provenance) {
return generate(rcontext, new ResourceWrapperDirect(r), (Provenance) r);
} else if (r instanceof DiagnosticReport) { } else if (r instanceof DiagnosticReport) {
inject(r, generateDiagnosticReport(new ResourceWrapperDirect(r)), NarrativeStatus.GENERATED); // Maintainer = Grahame inject(r, generateDiagnosticReport(new ResourceWrapperDirect(r)), NarrativeStatus.GENERATED); // Maintainer = Grahame
return true; return true;
@ -374,6 +378,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
} }
} }
private boolean generateByLiquid(ResourceContext rcontext, DomainResource r, String liquidTemplate, Set<String> outputTracker) { private boolean generateByLiquid(ResourceContext rcontext, DomainResource r, String liquidTemplate, Set<String> outputTracker) {
LiquidEngine engine = new LiquidEngine(context, services); LiquidEngine engine = new LiquidEngine(context, services);
@ -1511,8 +1516,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
else if (e instanceof InstantType) else if (e instanceof InstantType)
x.addText(((InstantType) e).toHumanDisplay()); x.addText(((InstantType) e).toHumanDisplay());
else if (e instanceof DateTimeType) { else if (e instanceof DateTimeType) {
if (e.hasPrimitiveValue()) renderDateTime(x, e);
x.addText(((DateTimeType) e).toHumanDisplay());
} else if (e instanceof Base64BinaryType) } else if (e instanceof Base64BinaryType)
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue())); x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
else if (e instanceof org.hl7.fhir.r5.model.DateType) else if (e instanceof org.hl7.fhir.r5.model.DateType)
@ -1566,35 +1570,10 @@ public class NarrativeGenerator implements INarrativeGenerator {
renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails); renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
} else if (e instanceof Period) { } else if (e instanceof Period) {
Period p = (Period) e; Period p = (Period) e;
x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay()); renderPeriod(x, p);
x.tx(" --> ");
x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
} else if (e instanceof Reference) { } else if (e instanceof Reference) {
Reference r = (Reference) e; Reference r = (Reference) e;
XhtmlNode c = x; renderReference(rc, res, x, r);
ResourceWithReference tr = null;
if (r.hasReferenceElement()) {
tr = resolveReference(res, r.getReference(), rc);
if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null)
c = x.ah(tr.getReference());
else
c = x.ah(r.getReference());
}
}
// what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
if (r.hasDisplayElement()) {
c.addText(r.getDisplay());
if (tr != null && tr.getResource() != null) {
c.tx(". Generated Summary: ");
generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"), rc);
}
} else if (tr != null && tr.getResource() != null) {
generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"), rc);
} else {
c.addText(r.getReference());
}
} else if (e instanceof Resource) { } else if (e instanceof Resource) {
return; return;
} else if (e instanceof ElementDefinition) { } else if (e instanceof ElementDefinition) {
@ -1609,6 +1588,44 @@ public class NarrativeGenerator implements INarrativeGenerator {
} }
} }
public void renderReference(ResourceContext rc, ResourceWrapper res, XhtmlNode x, Reference r) throws UnsupportedEncodingException, IOException {
XhtmlNode c = x;
ResourceWithReference tr = null;
if (r.hasReferenceElement()) {
tr = resolveReference(res, r.getReference(), rc);
if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null)
c = x.ah(tr.getReference());
else
c = x.ah(r.getReference());
}
}
// what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
if (r.hasDisplayElement()) {
c.addText(r.getDisplay());
if (tr != null && tr.getResource() != null) {
c.tx(". Generated Summary: ");
generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"), rc);
}
} else if (tr != null && tr.getResource() != null) {
generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"), rc);
} else {
c.addText(r.getReference());
}
}
public void renderDateTime(XhtmlNode x, Base e) {
if (e.hasPrimitiveValue())
x.addText(((DateTimeType) e).toHumanDisplay());
}
public void renderPeriod(XhtmlNode x, Period p) {
x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
x.tx(" --> ");
x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
}
private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails, ResourceContext rc) throws FHIRException, UnsupportedEncodingException, IOException { private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails, ResourceContext rc) throws FHIRException, UnsupportedEncodingException, IOException {
if (ew == null) if (ew == null)
return false; return false;
@ -1870,6 +1887,10 @@ public class NarrativeGenerator implements INarrativeGenerator {
} }
private void renderCodeableConcept(CodeableConcept cc, XhtmlNode x, boolean showCodeDetails) { private void renderCodeableConcept(CodeableConcept cc, XhtmlNode x, boolean showCodeDetails) {
if (cc.isEmpty()) {
return;
}
String s = cc.getText(); String s = cc.getText();
if (Utilities.noString(s)) { if (Utilities.noString(s)) {
for (Coding c : cc.getCoding()) { for (Coding c : cc.getCoding()) {
@ -2111,6 +2132,13 @@ public class NarrativeGenerator implements INarrativeGenerator {
x.addText(displayContactPoint(contact)); x.addText(displayContactPoint(contact));
} }
private void renderUri(XhtmlNode x, UriType uri) {
if (uri.getValue().startsWith("mailto:"))
x.ah(uri.getValue()).addText(uri.getValue().substring(7));
else
x.ah(uri.getValue()).addText(uri.getValue());
}
private void renderUri(UriType uri, XhtmlNode x, String path, String id) { private void renderUri(UriType uri, XhtmlNode x, String path, String id) {
String url = uri.getValue(); String url = uri.getValue();
if (isCanonical(path)) { if (isCanonical(path)) {
@ -2425,8 +2453,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
return XMLUtil.getNamedChild(txt, "div"); return XMLUtil.getNamedChild(txt, "div");
} }
public void inject(Element er, XhtmlNode x, NarrativeStatus status) {
private void inject(Element er, XhtmlNode x, NarrativeStatus status) {
if (!x.hasAttribute("xmlns")) if (!x.hasAttribute("xmlns"))
x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
Element le = XMLUtil.getNamedChild(er, "language"); Element le = XMLUtil.getNamedChild(er, "language");
@ -2468,7 +2495,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
new XhtmlComposer(XhtmlComposer.XML, pretty).compose(div, x); new XhtmlComposer(XhtmlComposer.XML, pretty).compose(div, x);
} }
private void inject(org.hl7.fhir.r5.elementmodel.Element er, XhtmlNode x, NarrativeStatus status) throws IOException, FHIRException { public void inject(org.hl7.fhir.r5.elementmodel.Element er, XhtmlNode x, NarrativeStatus status) throws IOException, FHIRException {
if (!x.hasAttribute("xmlns")) if (!x.hasAttribute("xmlns"))
x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
String l = er.getChildValue("language"); String l = er.getChildValue("language");
@ -2500,6 +2527,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
txt.getChildren().add(div); txt.getChildren().add(div);
div.setValue(new XhtmlComposer(XhtmlComposer.XML, pretty).compose(x)); div.setValue(new XhtmlComposer(XhtmlComposer.XML, pretty).compose(x));
} }
div.setValue(x.toString());
div.setXhtml(x); div.setXhtml(x);
} }
@ -3716,4 +3744,126 @@ public class NarrativeGenerator implements INarrativeGenerator {
p.addText(lines[i]); p.addText(lines[i]);
} }
} }
private boolean generate(ResourceContext rcontext, ResourceWrapper res, Provenance r) throws UnsupportedEncodingException, IOException {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
boolean hasExtensions = false;
if (!r.getTarget().isEmpty()) {
if (r.getTarget().size() == 1) {
XhtmlNode p = x.para();
p.tx("This provenance relates to ");
renderReference(rcontext, res, p, r.getTargetFirstRep());
} else {
x.para().tx("This provenance relates to:");
XhtmlNode ul = x.ul();
for (Reference ref : r.getTarget()) {
renderReference(rcontext, res, ul.li(), r.getTargetFirstRep());
}
}
}
// summary table
x.para().tx("Summary");
XhtmlNode t = x.table("grid");
XhtmlNode tr;
if (r.hasOccurred()) {
tr = t.tr();
tr.td().tx("Occurrence");
if (r.hasOccurredPeriod()) {
renderPeriod(tr.td(), r.getOccurredPeriod());
} else {
renderDateTime(tr.td(), r.getOccurredDateTimeType());
}
}
if (r.hasRecorded()) {
tr = t.tr();
tr.td().tx("Recorded");
tr.td().addText(r.getRecordedElement().toHumanDisplay());
}
if (r.hasPolicy()) {
tr = t.tr();
tr.td().tx("Policy");
if (r.getPolicy().size() == 1) {
renderUri(tr.td(), r.getPolicy().get(0));
} else {
XhtmlNode ul = tr.td().ul();
for (UriType u : r.getPolicy()) {
renderUri(ul.li(), u);
}
}
}
if (r.hasLocation()) {
tr = t.tr();
tr.td().tx("Location");
renderReference(rcontext, res, tr.td(), r.getLocation());
}
if (r.hasActivity()) {
tr = t.tr();
tr.td().tx("Activity");
renderCodeableConcept(r.getActivity(), tr.td(), false);
}
boolean hasType = false;
boolean hasRole = false;
boolean hasOnBehalfOf = false;
for (ProvenanceAgentComponent a : r.getAgent()) {
hasType = hasType || a.hasType();
hasRole = hasRole || a.hasRole();
hasOnBehalfOf = hasOnBehalfOf || a.hasOnBehalfOf();
}
x.para().tx("Agents");
t = x.table("grid");
tr = t.tr();
if (hasType) {
tr.td().b().tx("type");
}
if (hasRole) {
tr.td().b().tx("role");
}
tr.td().b().tx("who");
if (hasOnBehalfOf) {
tr.td().b().tx("onBehalfOf");
}
for (ProvenanceAgentComponent a : r.getAgent()) {
tr = t.tr();
if (hasType) {
if (a.hasType()) {
renderCodeableConcept(a.getType(), tr.td(), false);
} else {
tr.td();
}
}
if (hasRole) {
if (a.hasRole()) {
if (a.getRole().size() == 1) {
renderCodeableConcept(a.getType(), tr.td(), false);
} else {
XhtmlNode ul = tr.td().ul();
for (CodeableConcept cc : a.getRole()) {
renderCodeableConcept(cc, ul.li(), false);
}
}
} else {
tr.td();
}
}
if (a.hasWho()) {
renderReference(rcontext, res, tr.td(), a.getWho());
} else {
tr.td();
}
if (hasOnBehalfOf) {
if (a.hasOnBehalfOf()) {
renderReference(rcontext, res, tr.td(), a.getOnBehalfOf());
} else {
tr.td();
}
}
}
// agent table
inject(r, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
return hasExtensions;
}
} }