use of org.hl7.fhir.dstu3.model.ListResource in project org.hl7.fhir.core by hapifhir.
the class ArgonautConverter method processImmunizationsSection.
private void processImmunizationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Immunizations", section);
ListResource list = new ListResource();
list.setId(context.getBaseId() + "-list-immunizations");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafimmunizationlist");
list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.SNAPSHOT);
list.setDateElement(context.getNow());
list.setSource(context.getAuthorRef());
buildNarrative(list, cda.getChild(section, "text"));
int i = 0;
for (Element c : cda.getChildren(section, "entry")) {
// allergy problem act
Element sa = cda.getChild(c, "substanceAdministration");
Immunization imm = new Immunization();
imm.setId(context.getBaseId() + "-immunization-" + i);
imm.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/immunization-daf-dafimmunization");
i++;
imm.setPatient(context.getSubjectRef());
imm.setEncounter(new Reference().setReference("Encounter/" + context.getEncounter().getId()));
imm.setNotGiven("true".equals(sa.getAttribute("negationInd")));
imm.setStatus(convertImmunizationStatus(cda.getChild(sa, "statusCode")));
boolean found = false;
for (Element e : cda.getChildren(sa, "id")) {
Identifier id = convert.makeIdentifierFromII(e);
imm.getIdentifier().add(id);
}
if (!found) {
list.addEntry().setItem(new Reference().setReference("Immunization/" + imm.getId()));
imm.setDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(sa, "effectiveTime"), "low")));
if (imm.getNotGiven()) {
Element reason = cda.getChild(cda.getChildByAttribute(sa, "entryRelationship", "typeCode", "RSON"), "observation");
imm.setExplanation(new ImmunizationExplanationComponent());
imm.getExplanation().addReasonNotGiven(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(reason, "code")), null));
}
Element mm = cda.getChild(cda.getChild(cda.getChild(sa, "consumable"), "manufacturedProduct"), "manufacturedMaterial");
imm.setVaccineCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(mm, "code")), null));
imm.setRoute(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sa, "routeCode")), null));
if (cda.getChild(mm, "lotNumberText") != null)
imm.setLotNumber(cda.getChild(mm, "lotNumberText").getTextContent());
Element mr = cda.getChild(cda.getChild(cda.getChild(sa, "consumable"), "manufacturedProduct"), "manufacturerOrganization");
if (mr != null)
imm.setManufacturer(new Reference().setDisplay(cda.getChild(mr, "name").getTextContent()));
// the problem with this is that you can't have just a dose sequence number
// Element subject = cda.getChild(cda.getChildByAttribute(sa, "entryRelationship", "typeCode", "SUBJ"), "observation");
// if (subject != null)
// imm.addVaccinationProtocol().setDoseSequence(Integer.parseInt(cda.getChild(subject, "value").getAttribute("value")));
boolean hasprf = false;
for (Element e : cda.getChildren(sa, "performer")) {
if (imm.hasPractitioner())
throw new Error("additional performer discovered");
Practitioner p = processPerformer(cda, convert, context, e, "assignedEntity", "assignedPerson");
Reference ref = new Reference().setReference("Practitioner/" + p.getId()).setDisplay(p.getUserString("display"));
imm.addPractitioner().setActor(ref).setRole(new org.hl7.fhir.dstu3.model.CodeableConcept().addCoding(new Coding().setSystem("http://hl7.org/fhir/v2/0443").setCode("AP")));
hasprf = true;
}
imm.setPrimarySource(hasprf);
saveResource(imm);
}
}
saveResource(list);
}
use of org.hl7.fhir.dstu3.model.ListResource 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);
}
use of org.hl7.fhir.dstu3.model.ListResource in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method addItemToList.
protected ListEntryComponent addItemToList(ListResource list, DomainResource ai) throws Exception {
list.getContained().add(ai);
String n = nextRef();
ai.setId(n);
ListEntryComponent item = new ListResource.ListEntryComponent();
list.getEntry().add(item);
item.setItem(Factory.makeReference("#" + n));
return item;
}
use of org.hl7.fhir.dstu3.model.ListResource in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method processSocialHistorySection.
protected SectionComponent processSocialHistorySection(Element section) throws Exception {
ListResource list = new ListResource();
for (Element entry : cda.getChildren(section, "entry")) {
Element observation = cda.getlastChild(entry);
if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.22.4.38")) {
processSocialObservation(list, observation, SocialHistoryType.SocialHistory);
} else if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.15.3.8")) {
processSocialObservation(list, observation, SocialHistoryType.Pregnancy);
} else if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.22.4.78")) {
processSocialObservation(list, observation, SocialHistoryType.SmokingStatus);
} else if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.22.4.85")) {
processSocialObservation(list, observation, SocialHistoryType.TobaccoUse);
} else
throw new Exception("Unhandled Section template ids: " + cda.showTemplateIds(observation));
}
// todo: text
SectionComponent s = new Composition.SectionComponent();
s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")));
// todo: check subject
s.addEntry(Factory.makeReference(addReference(list, "Procedures", makeUUIDReference())));
return s;
}
use of org.hl7.fhir.dstu3.model.ListResource in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method processProceduresSection.
protected SectionComponent processProceduresSection(Element section) throws Exception {
ListResource list = new ListResource();
for (Element entry : cda.getChildren(section, "entry")) {
Element procedure = cda.getlastChild(entry);
if (cda.hasTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.14")) {
processProcedure(list, procedure, ProcedureType.Procedure);
} else if (cda.hasTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.13")) {
processProcedure(list, procedure, ProcedureType.Observation);
} else if (cda.hasTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.12")) {
processProcedure(list, procedure, ProcedureType.Act);
} else
throw new Exception("Unhandled Section template ids: " + cda.showTemplateIds(procedure));
}
// todo: text
SectionComponent s = new Composition.SectionComponent();
s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")));
// todo: check subject
s.addEntry(Factory.makeReference(addReference(list, "Procedures", makeUUIDReference())));
return s;
}
Aggregations