use of org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method processProcedure.
protected void processProcedure(ListResource list, Element procedure, ProcedureType type) throws Exception {
switch(type) {
case Procedure:
cda.checkTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.14");
break;
case Observation:
cda.checkTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.13");
break;
case Act:
cda.checkTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.12");
}
checkNoNegationOrNullFlavor(procedure, "Procedure (" + type + ")");
checkNoSubject(procedure, "Procedure (" + type + ")");
Procedure p = new Procedure();
addItemToList(list, p);
// moodCode is either INT or EVN. INT is not handled yet. INT is deprecated anyway
if (procedure.getAttribute("moodCode").equals("INT"))
p.getModifierExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-planned", Factory.newBoolean(true), false));
// SHALL contain at least one [1..*] id (CONF:7655).
for (Element e : cda.getChildren(procedure, "id")) p.getIdentifier().add(convert.makeIdentifierFromII(e));
// SHALL contain exactly one [1..1] code (CONF:7656).
// This code @code in a procedure activity SHOULD be selected from LOINC or SNOMED CT and MAY be selected from CPT-4, ICD9 Procedures, ICD10 Procedures
p.setCode(convert.makeCodeableConceptFromCD(cda.getChild(procedure, "code")));
// SHALL contain exactly one [1..1] statusCode/@code, which SHALL be selected from ValueSet 2.16.840.1.113883.11.20.9.22 ProcedureAct
// completed | active | aborted | cancelled - not in FHIR
p.getModifierExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-status", Factory.newCode(cda.getStatus(procedure)), false));
// SHOULD contain zero or one [0..1] effectiveTime (CONF:7662).
p.setPerformed(convert.makePeriodFromIVL(cda.getChild(procedure, "effectiveTime")));
// MAY contain zero or one [0..1] priorityCode/@code, which SHALL be selected from ValueSet 2.16.840.1.113883.1.11.16866 ActPriority DYNAMIC (CONF:7668)
p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-priority", convert.makeCodeableConceptFromCD(cda.getChild(procedure, "priorityCode")), false));
// MAY contain zero or one [0..1] methodCode (CONF:7670).
p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-method", convert.makeCodeableConceptFromCD(cda.getChild(procedure, "methodCode")), false));
if (type == ProcedureType.Observation) {
// for Procedure-Observation:
// 9. SHALL contain exactly one [1..1] value (CONF:16846).
// don't know what this is. It's not the actual result of the procedure (that goes in results "This section records ... procedure observations"), and there seems to be no value. The example as <value xsi:type="CD"/> which is not valid
// so we ignore this for now
}
// SHOULD contain zero or more [0..*] targetSiteCode/@code, which SHALL be selected from ValueSet 2.16.840.1.113883.3.88.12.3221.8.9 Body site DYNAMIC (CONF:7683).
for (Element e : cda.getChildren(procedure, "targetSiteCode")) p.addBodySite(convert.makeCodeableConceptFromCD(e));
// SHOULD contain zero or more [0..*] performer (CONF:7718) such that it
for (Element e : cda.getChildren(procedure, "performer")) {
ProcedurePerformerComponent pp = new ProcedurePerformerComponent();
p.getPerformer().add(pp);
pp.setActor(makeReferenceToPractitionerForAssignedEntity(e, p));
}
for (Element participant : cda.getChildren(procedure, "participant")) {
Element participantRole = cda.getlastChild(participant);
if (type == ProcedureType.Procedure && cda.hasTemplateId(participantRole, "2.16.840.1.113883.10.20.22.4.37")) {
// MAY contain zero or more [0..*] participant (CONF:7751) such that it SHALL contain exactly one [1..1] @typeCode="DEV" Device
// implanted devices
p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/implanted-devices", Factory.makeReference(processDevice(participantRole, p)), false));
} else if (cda.hasTemplateId(participantRole, "2.16.840.1.113883.10.20.22.4.32")) {
// MAY contain zero or more [0..*] participant (CONF:7765) such that it SHALL contain exactly one [1..1] Service Delivery Location (templateId:2.16.840.1.113883.10.20.22.4.32) (CONF:7767)
p.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/location", Factory.makeReference(processSDLocation(participantRole, p)), false));
}
}
for (Element e : cda.getChildren(procedure, "entryRelationship")) {
Element a = /* act*/
cda.getlastChild(e);
if (a.getLocalName().equals("encounter")) {
// MAY contain zero or more [0..*] entryRelationship (CONF:7768) such that it SHALL contain exactly one encounter which SHALL contain exactly one [1..1] id (CONF:7773).
// todo - and process as a full encounter while we're at it
} else if (cda.hasTemplateId(a, "2.16.840.1.113883.10.20.22.4.20")) {
// MAY contain zero or one [0..1] entryRelationship (CONF:7775) such that it SHALL contain exactly one [1..1] Instructions (templateId:2.16.840.1.113883.10.20.22.4.20) (CONF:7778).
// had code for type, plus text for instructions
Extension n = Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-instructions", null, true);
n.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-instructions-type", convert.makeCodeableConceptFromCD(cda.getChild(a, "code")), false));
n.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/procedure-instructions-text", convert.makeStringFromED(cda.getChild(a, "text")), false));
p.getExtension().add(n);
} else if (cda.hasTemplateId(a, "2.16.840.1.113883.10.20.22.4.19")) {
// MAY contain zero or more [0..*] entryRelationship (CONF:7779) such that it SHALL contain exactly one [1..1] Indication (templateId:2.16.840.1.113883.10.20.22.4.19) (CONF:7781).
p.addReasonCode(processIndication(a));
} else if (cda.hasTemplateId(cda.getlastChild(e), "2.16.840.1.113883.10.20.22.4.16")) {
// MAY contain zero or one [0..1] entryRelationship (CONF:7886) such that it SHALL contain exactly one [1..1] Medication Activity (templateId:2.16.840.1.113883.10.20.22.4.16) (CONF:7888).
// todo
}
}
}
use of org.hl7.fhir.dstu3.model.Procedure.ProcedurePerformerComponent in project org.hl7.fhir.core by hapifhir.
the class ArgonautConverter method processProcedureSection.
private void processProcedureSection(CDAUtilities cda, Convert convert, Element sect, Context context) throws Exception {
scanSection("Procedures", sect);
ListResource list = new ListResource();
list.setId(context.getBaseId() + "-list-procedures");
// list.setUserData("profile", "") none?
list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sect, "code")), null));
list.setTitle(cda.getChild(sect, "title").getTextContent());
list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.getNow());
list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(sect, "text"));
int i = 0;
for (Element c : cda.getChildren(sect, "entry")) {
Element p = cda.getChild(c, "procedure");
Procedure proc = new Procedure();
proc.setId(context.getBaseId() + "-procedure-" + i);
proc.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/procedure-daf-dafprocedure");
i++;
proc.setSubject(context.getSubjectRef());
proc.setContext(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
list.addEntry().setItem(new Reference().setReference("Procedure/" + proc.getId()));
proc.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(p, "code")), null));
recordProcedureCode(proc.getCode());
for (Element e : cda.getChildren(p, "id")) proc.getIdentifier().add(convert.makeIdentifierFromII(e));
proc.setStatus(determineProcedureStatus(cda.getChild(p, "statusCode")));
buildNarrative(proc, cda.getChild(p, "text"));
proc.setPerformed(convert.makeDateTimeFromTS(cda.getChild(p, "effectiveTime")));
for (Element e : cda.getChildren(p, "performer")) {
ProcedurePerformerComponent part = proc.addPerformer();
Practitioner pp = processPerformer(cda, convert, context, e, "assignedEntity", "assignedPerson");
Reference ref = new Reference().setReference("Practitioner/" + pp.getId()).setDisplay(pp.getUserString("display"));
part.setActor(ref);
}
saveResource(proc);
}
saveResource(list);
}
Aggregations