use of org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent in project synthea by synthetichealth.
the class FhirR4 method provenance.
/**
* Create a Provenance entry at the end of this Bundle that
* targets all the entries in the Bundle.
*
* @param bundle The finished complete Bundle.
* @param person The person.
* @param stopTime The time the simulation stopped.
* @return BundleEntryComponent containing a Provenance resource.
*/
private static BundleEntryComponent provenance(Bundle bundle, Person person, long stopTime) {
Provenance provenance = new Provenance();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-provenance");
provenance.setMeta(meta);
}
for (BundleEntryComponent entry : bundle.getEntry()) {
provenance.addTarget(new Reference(entry.getFullUrl()));
}
provenance.setRecorded(new Date(stopTime));
// Provenance sources...
int index = person.record.encounters.size() - 1;
Clinician clinician = null;
while (index >= 0 && clinician == null) {
clinician = person.record.encounters.get(index).clinician;
index--;
}
String clinicianDisplay = null;
if (clinician != null) {
clinicianDisplay = clinician.getFullname();
}
String practitionerFullUrl = TRANSACTION_BUNDLE ? ExportHelper.buildFhirNpiSearchUrl(clinician) : findPractitioner(clinician, bundle);
Provider providerOrganization = person.record.provider;
if (providerOrganization == null) {
providerOrganization = person.getProvider(EncounterType.WELLNESS, stopTime);
}
String organizationFullUrl = TRANSACTION_BUNDLE ? ExportHelper.buildFhirSearchUrl("Organization", providerOrganization.getResourceID()) : findProviderUrl(providerOrganization, bundle);
// Provenance Author...
ProvenanceAgentComponent agent = provenance.addAgent();
agent.setType(mapCodeToCodeableConcept(new Code("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "author", "Author"), null));
agent.setWho(new Reference().setReference(practitionerFullUrl).setDisplay(clinicianDisplay));
agent.setOnBehalfOf(new Reference().setReference(organizationFullUrl).setDisplay(providerOrganization.name));
// Provenance Transmitter...
agent = provenance.addAgent();
agent.setType(mapCodeToCodeableConcept(new Code("http://hl7.org/fhir/us/core/CodeSystem/us-core-provenance-participant-type", "transmitter", "Transmitter"), null));
agent.setWho(new Reference().setReference(practitionerFullUrl).setDisplay(clinicianDisplay));
agent.setOnBehalfOf(new Reference().setReference(organizationFullUrl).setDisplay(providerOrganization.name));
return newEntry(person, bundle, provenance);
}
use of org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent in project org.hl7.fhir.core by hapifhir.
the class UTGVersionSorter method execute.
private void execute(String source) throws IOException {
List<CanonicalResourceAnalysis> list = new ArrayList<>();
System.out.println("Loading UTG");
loadFromSource(list, new File(source));
Map<String, CanonicalResource> r2 = loadPackageR2("hl7.fhir.r2.core");
Map<String, CanonicalResource> r3 = loadPackageR3("hl7.fhir.r3.core");
Map<String, CanonicalResource> r4 = loadPackageR4("hl7.fhir.r4.core");
System.out.println("Processing");
for (CanonicalResourceAnalysis cr : list) {
cr.analyse(r2, r3, r4);
}
Bundle b = (Bundle) new JsonParser().parse(new FileInputStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"));
System.out.println("Summary");
for (CanonicalResourceAnalysis cr : list) {
System.out.println(cr.summary());
Provenance p = new Provenance();
b.addEntry().setResource(p).setFullUrl("http://terminology.hl7.org/fhir/Provenance/fhir-1.0.51-" + cr.getId());
p.setId("hx-fhir-1.0.51-" + cr.getId());
p.addTarget().setReference(cr.fhirType() + "/" + cr.getId());
p.getOccurredPeriod().setEnd(runTime, TemporalPrecisionEnum.DAY);
p.setRecorded(runTime);
p.addAuthorization().getConcept().setText("Reset Version after migration to UTG").addCoding("http://terminology.hl7.org/CodeSystem/v3-ActReason", "METAMGT", null);
p.getActivity().addCoding("http://terminology.hl7.org/CodeSystem/v3-DataOperation", "UPDATE", null);
ProvenanceAgentComponent pa = p.addAgent();
pa.getType().addCoding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "author", null);
pa.getWho().setDisplay("Grahame Grieve");
pa = p.addAgent();
pa.getType().addCoding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "custodian", null);
pa.getWho().setDisplay("Vocabulary WG");
CanonicalResource res = cr.resource;
res.setVersion(cr.recommendation);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(cr.filename), res);
}
System.out.println();
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("C:\\work\\org.hl7.fhir.igs\\UTG\\input\\sourceOfTruth\\history\\utgrel1hx-1-0-6.json"), b);
System.out.println("Done");
}
use of org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent in project org.hl7.fhir.core by hapifhir.
the class UTGCaseSensitivePopulator method processCodeSystem.
private boolean processCodeSystem(CodeSystem cs, Bundle bundle, Date d, Date dt) {
if (cs.hasCaseSensitive()) {
return false;
}
if (!cs.getUrl().startsWith("http://terminology.hl7.org") || cs.getContent() == CodeSystemContentMode.NOTPRESENT) {
return false;
}
cs.setCaseSensitive(true);
Provenance p = new Provenance();
p.setId("cs-286-" + cs.getId());
p.addTarget().setReference("CodeSystem/" + cs.getId());
p.setOccurred(new Period());
p.getOccurredPeriod().setEnd(d);
p.setRecorded(dt);
p.addReason().setText("Populate Missing caseSensitive property;UP-286").addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-ActReason").setCode("METAMGT");
p.getActivity().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-DataOperation").setCode("UPDATE");
ProvenanceAgentComponent agent = p.addAgent();
agent.getType().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/provenance-participant-type").setCode("author");
agent.getWho().setDisplay("Grahame Grieve");
agent = p.addAgent();
agent.getType().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/provenance-participant-type").setCode("custodian");
agent.getWho().setDisplay("Vocabulary WG");
bundle.addEntry().setFullUrl("http://terminology.hl7.org/fhir/Provenance/cs-286-" + cs.getId()).setResource(p);
return true;
}
use of org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent in project org.hl7.fhir.core by hapifhir.
the class ProvenanceRenderer method render.
public boolean render(XhtmlNode x, Provenance prv) throws UnsupportedEncodingException, IOException {
boolean hasExtensions = false;
if (!prv.getTarget().isEmpty()) {
if (prv.getTarget().size() == 1) {
XhtmlNode p = x.para();
p.tx("Provenance for ");
renderReference(prv, p, prv.getTargetFirstRep());
} else {
x.para().tx("Provenance for:");
XhtmlNode ul = x.ul();
for (Reference ref : prv.getTarget()) {
renderReference(prv, ul.li(), ref);
}
}
}
// summary table
x.para().tx("Summary");
XhtmlNode t = x.table("grid");
XhtmlNode tr;
if (prv.hasOccurred()) {
tr = t.tr();
tr.td().tx("Occurrence");
if (prv.hasOccurredPeriod()) {
renderPeriod(tr.td(), prv.getOccurredPeriod());
} else {
renderDateTime(tr.td(), prv.getOccurredDateTimeType());
}
}
if (prv.hasRecorded()) {
tr = t.tr();
tr.td().tx("Recorded");
tr.td().addText(prv.getRecordedElement().toHumanDisplay());
}
if (prv.hasPolicy()) {
tr = t.tr();
tr.td().tx("Policy");
if (prv.getPolicy().size() == 1) {
renderUri(tr.td(), prv.getPolicy().get(0));
} else {
XhtmlNode ul = tr.td().ul();
for (UriType u : prv.getPolicy()) {
renderUri(ul.li(), u);
}
}
}
if (prv.hasLocation()) {
tr = t.tr();
tr.td().tx("Location");
renderReference(prv, tr.td(), prv.getLocation());
}
if (prv.hasActivity()) {
tr = t.tr();
tr.td().tx("Activity");
renderCodeableConcept(tr.td(), prv.getActivity(), false);
}
boolean hasType = false;
boolean hasRole = false;
boolean hasOnBehalfOf = false;
for (ProvenanceAgentComponent a : prv.getAgent()) {
hasType = hasType || a.hasType();
hasRole = hasRole || a.hasRole();
hasOnBehalfOf = hasOnBehalfOf || a.hasOnBehalfOf();
}
x.para().b().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("On Behalf Of");
}
for (ProvenanceAgentComponent a : prv.getAgent()) {
tr = t.tr();
if (hasType) {
if (a.hasType()) {
renderCodeableConcept(tr.td(), a.getType(), false);
} else {
tr.td();
}
}
if (hasRole) {
if (a.hasRole()) {
if (a.getRole().size() == 1) {
renderCodeableConcept(tr.td(), a.getType(), false);
} else {
XhtmlNode ul = tr.td().ul();
for (CodeableConcept cc : a.getRole()) {
renderCodeableConcept(ul.li(), cc, false);
}
}
} else {
tr.td();
}
}
if (a.hasWho()) {
renderReference(prv, tr.td(), a.getWho());
} else {
tr.td();
}
if (hasOnBehalfOf) {
if (a.hasOnBehalfOf()) {
renderReference(prv, tr.td(), a.getOnBehalfOf());
} else {
tr.td();
}
}
}
return hasExtensions;
}
use of org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent in project org.hl7.fhir.core by hapifhir.
the class ProvenanceRenderer method render.
public boolean render(XhtmlNode x, Provenance prv) throws UnsupportedEncodingException, IOException {
boolean hasExtensions = false;
if (!prv.getTarget().isEmpty()) {
if (prv.getTarget().size() == 1) {
XhtmlNode p = x.para();
p.tx("Provenance for ");
renderReference(prv, p, prv.getTargetFirstRep());
} else {
x.para().tx("Provenance for:");
XhtmlNode ul = x.ul();
for (Reference ref : prv.getTarget()) {
renderReference(prv, ul.li(), ref);
}
}
}
// summary table
x.para().tx("Summary");
XhtmlNode t = x.table("grid");
XhtmlNode tr;
if (prv.hasOccurred()) {
tr = t.tr();
tr.td().tx("Occurrence");
if (prv.hasOccurredPeriod()) {
renderPeriod(tr.td(), prv.getOccurredPeriod());
} else {
renderDateTime(tr.td(), prv.getOccurredDateTimeType());
}
}
if (prv.hasRecorded()) {
tr = t.tr();
tr.td().tx("Recorded");
tr.td().addText(prv.getRecordedElement().toHumanDisplay());
}
if (prv.hasPolicy()) {
tr = t.tr();
tr.td().tx("Policy");
if (prv.getPolicy().size() == 1) {
renderUri(tr.td(), prv.getPolicy().get(0));
} else {
XhtmlNode ul = tr.td().ul();
for (UriType u : prv.getPolicy()) {
renderUri(ul.li(), u);
}
}
}
if (prv.hasLocation()) {
tr = t.tr();
tr.td().tx("Location");
renderReference(prv, tr.td(), prv.getLocation());
}
if (prv.hasActivity()) {
tr = t.tr();
tr.td().tx("Activity");
renderCodeableConcept(tr.td(), prv.getActivity(), false);
}
boolean hasType = false;
boolean hasRole = false;
boolean hasOnBehalfOf = false;
for (ProvenanceAgentComponent a : prv.getAgent()) {
hasType = hasType || a.hasType();
hasRole = hasRole || a.hasRole();
hasOnBehalfOf = hasOnBehalfOf || a.hasOnBehalfOf();
}
x.para().b().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("On Behalf Of");
}
for (ProvenanceAgentComponent a : prv.getAgent()) {
tr = t.tr();
if (hasType) {
if (a.hasType()) {
renderCodeableConcept(tr.td(), a.getType(), false);
} else {
tr.td();
}
}
if (hasRole) {
if (a.hasRole()) {
if (a.getRole().size() == 1) {
renderCodeableConcept(tr.td(), a.getType(), false);
} else {
XhtmlNode ul = tr.td().ul();
for (CodeableConcept cc : a.getRole()) {
renderCodeableConcept(ul.li(), cc, false);
}
}
} else {
tr.td();
}
}
if (a.hasWho()) {
renderReference(prv, tr.td(), a.getWho());
} else {
tr.td();
}
if (hasOnBehalfOf) {
if (a.hasOnBehalfOf()) {
renderReference(prv, tr.td(), a.getOnBehalfOf());
} else {
tr.td();
}
}
}
return hasExtensions;
}
Aggregations