use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project integration-adaptor-111 by nhsconnect.
the class ConsentMapper method extractConsentSource.
private void extractConsentSource(Consent consent, POCDMT000002UK01StructuredBody structuredBody) {
List<POCDMT000002UK01Section> sections = getSectionsOfType(structuredBody);
sections.stream().filter(POCDMT000002UK01Section::isSetId).forEach(section -> consent.setSource(new Identifier().setValue(section.getId().getRoot())));
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project integration-adaptor-111 by nhsconnect.
the class ConsentMapperTest method setUp.
@BeforeEach
public void setUp() {
POCDMT000002UK01Component2 component2 = mock(POCDMT000002UK01Component2.class);
POCDMT000002UK01Component3 component3 = mock(POCDMT000002UK01Component3.class);
POCDMT000002UK01Authorization authorization = mock(POCDMT000002UK01Authorization.class);
POCDMT000002UK01StructuredBody structuredBody = mock(POCDMT000002UK01StructuredBody.class);
code = CE.Factory.newInstance();
code.setCodeSystem(ITK_SNOMED);
code.setCode(INFORMATION_ADVICE_GIVEN);
code.setDisplayName(CODE_DISPLAY_NAME);
title.setLanguage(LANG);
cs.setCode(LANG);
when(clinicalDocument.getComponent()).thenReturn(component2);
when(clinicalDocument.sizeOfAuthorizationArray()).thenReturn(1);
when(clinicalDocument.getAuthorizationArray()).thenReturn(new POCDMT000002UK01Authorization[] { authorization });
when(authorization.getConsent()).thenReturn(authConsent);
when(authConsent.isSetCode()).thenReturn(true);
when(authConsent.getCode()).thenReturn(code);
when(component2.getStructuredBody()).thenReturn(structuredBody);
when(component3.getSection()).thenReturn(section);
when(component5.getSection()).thenReturn(section);
when(structuredBody.getComponentArray()).thenReturn(new POCDMT000002UK01Component3[] { component3 });
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project integration-adaptor-111 by nhsconnect.
the class ObservationMapper method mapObservations.
public List<Observation> mapObservations(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter) {
List<Observation> observations = new ArrayList<>();
POCDMT000002UK01Component2 component = clinicalDocument.getComponent();
if (component.isSetStructuredBody()) {
POCDMT000002UK01Component3[] components = component.getStructuredBody().getComponentArray();
for (POCDMT000002UK01Component3 component3 : components) {
POCDMT000002UK01Section section = component3.getSection();
for (POCDMT000002UK01Component5 component5 : section.getComponentArray()) {
ST title = component5.getSection().getTitle();
if (nodeUtil.getNodeValueString(title).matches(PATIENTS_CONDITION_REGEXP)) {
StrucDocContent[] contentArray = component5.getSection().getText().getContentArray();
List<String> sectionText = stream(contentArray).map(it -> nodeUtil.getNodeValueString(it)).collect(toList());
observations.add(createObservation(encounter, sectionText));
}
}
}
}
return observations;
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section 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.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.
the class ArgonautConverter method processMedicationsSection.
private void processMedicationsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Medications", section);
ListResource list = new ListResource();
list.setId(context.getBaseId() + "-list-medications");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafmedicationlist");
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");
MedicationStatement ms = new MedicationStatement();
ms.setId(context.getBaseId() + "-medication-" + i);
ms.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/medicationstatement-daf-dafmedicationstatement");
i++;
ms.setSubject(context.getSubjectRef());
boolean found = false;
for (Element e : cda.getChildren(sa, "id")) {
Identifier id = convert.makeIdentifierFromII(e);
ms.getIdentifier().add(id);
}
if (!found) {
ms.setStatus(MedicationStatementStatus.COMPLETED);
list.addEntry().setItem(new Reference().setReference("MedicationStatement/" + ms.getId()));
// allergy observation
Element mm = cda.getChild(cda.getChild(cda.getChild(sa, "consumable"), "manufacturedProduct"), "manufacturedMaterial");
ms.setMedication(new Reference().setReference("#med"));
Medication med = new Medication();
med.setId("med");
med.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(mm, "code")), null));
ms.getContained().add(med);
Dosage dosage = ms.addDosage();
// allergy observation
Element qty = cda.getChild(sa, "doseQuantity");
try {
if (cda.getChild(qty, "low") != null) {
// todo: this is not correct?
dosage.getExtension().add(new Extension().setUrl("http://healthintersections.com.au/fhir/extensions/medication-statement-range").setValue(convert.makeRangeFromIVLPQ(qty)));
} else {
dosage.setDose(convert.makeQuantityFromPQ(qty));
}
} catch (Exception e) {
System.out.println(" invalid dose quantity '" + qty.getAttribute("value") + " " + qty.getAttribute("unit") + "' (" + e.getClass().getName() + ") in " + context.getBaseId());
}
dosage.setRoute(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(sa, "routeCode")), null));
Type t = convert.makeSomethingFromGTS(cda.getChildren(sa, "effectiveTime"));
if (t instanceof Timing) {
dosage.setTiming((Timing) t);
if (dosage.getTiming().hasRepeat() && dosage.getTiming().getRepeat().hasBounds())
ms.setEffective(dosage.getTiming().getRepeat().getBounds());
} else if (t instanceof Period)
ms.setEffective(t);
else
throw new Exception("Undecided how to handle " + t.getClass().getName());
for (Element e : cda.getChildren(sa, "author")) {
if (ms.hasInformationSource())
throw new Error("additional author discovered");
Practitioner p = processPerformer(cda, convert, context, e, "assignedAuthor", "assignedPerson");
Reference ref = new Reference().setReference("Practitioner/" + p.getId()).setDisplay(p.getUserString("display"));
ms.setInformationSource(ref);
ms.setDateAssertedElement(convert.makeDateTimeFromTS(cda.getChild(e, "time")));
}
saveResource(ms);
}
}
saveResource(list);
}
Aggregations