use of org.hl7.fhir.r5.model.MarkdownType in project kindling by HL7.
the class Regenerator method generateOperation.
private void generateOperation(String root, ResourceDefn r, Operation op) throws IOException {
OperationDefinition opd = op.getResource().copy();
opd.setId(r.getName() + "-" + op.getName());
opd.setUrl("http://hl7.org/fhir/build/OperationDefinition/" + opd.getId());
if (!Utilities.noString(op.getFooter())) {
opd.addExtension(BuildExtensions.EXT_FOOTER, new MarkdownType(op.getFooter()));
}
if (!Utilities.noString(op.getFooter2())) {
opd.addExtension(BuildExtensions.EXT_FOOTER2, new MarkdownType(op.getFooter2()));
}
for (OperationExample opex : op.getExamples()) {
Extension ex = new Extension(BuildExtensions.EXT_OP_EXAMPLE);
if (!Utilities.noString(opex.getContent())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(opex.getContent()));
}
if (!Utilities.noString(opex.getComment())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_COMMENT, new StringType(opex.getComment()));
}
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(opex.isResponse()));
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new IntegerType(1));
opd.addExtension(ex);
}
for (OperationExample opex : op.getExamples2()) {
Extension ex = new Extension(BuildExtensions.EXT_OP_EXAMPLE);
if (!Utilities.noString(opex.getContent())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(opex.getContent()));
}
if (!Utilities.noString(opex.getComment())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_COMMENT, new StringType(opex.getComment()));
}
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(opex.isResponse()));
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new IntegerType(2));
opd.addExtension(ex);
}
File fn = new File(Utilities.path(root, opd.fhirType().toLowerCase() + "-" + opd.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), opd);
fn.setLastModified(r.getTimestamp());
}
use of org.hl7.fhir.r5.model.MarkdownType in project kindling by HL7.
the class ProfileGenerator method makeSearchParam.
public SearchParameter makeSearchParam(StructureDefinition p, String id, String rn, SearchParameterDefn spd, ResourceDefn rd) throws Exception {
boolean shared;
boolean created = true;
SearchParameter sp;
if (definitions.getCommonSearchParameters().containsKey(rn + "::" + spd.getCode())) {
shared = true;
CommonSearchParameter csp = definitions.getCommonSearchParameters().get(rn + "::" + spd.getCode());
if (csp.getDefinition() == null) {
sp = new SearchParameter();
csp.setDefinition(sp);
sp.setId(csp.getId());
} else {
created = false;
sp = csp.getDefinition();
}
} else {
shared = false;
sp = new SearchParameter();
sp.setId(id.replace("[", "").replace("]", ""));
}
spd.setCommonId(sp.getId());
if (created) {
sp.setUrl("http://hl7.org/fhir/SearchParameter/" + sp.getId());
sp.setVersion(version.toCode());
if (context.getSearchParameter(sp.getUrl()) != null)
throw new Exception("Duplicated Search Parameter " + sp.getUrl());
context.cacheResource(sp);
spd.setResource(sp);
definitions.addNs(sp.getUrl(), "Search Parameter: " + sp.getName(), rn.toLowerCase() + ".html#search");
sp.setStatus(spd.getStandardsStatus() == StandardsStatus.NORMATIVE ? PublicationStatus.fromCode("active") : PublicationStatus.fromCode("draft"));
StandardsStatus sst = ToolingExtensions.getStandardsStatus(sp);
if (sst == null || (spd.getStandardsStatus() == null && spd.getStandardsStatus().isLowerThan(sst)))
ToolingExtensions.setStandardsStatus(sp, spd.getStandardsStatus(), spd.getNormativeVersion());
sp.setExperimental(p.getExperimental());
sp.setName(spd.getCode());
sp.setCode(spd.getCode());
sp.setDate(genDate.getTime());
sp.setPublisher(p.getPublisher());
for (ContactDetail tc : p.getContact()) {
ContactDetail t = sp.addContact();
if (tc.hasNameElement())
t.setNameElement(tc.getNameElement().copy());
for (ContactPoint ts : tc.getTelecom()) t.getTelecom().add(ts.copy());
}
if (!definitions.hasResource(p.getType()) && !p.getType().equals("Resource") && !p.getType().equals("DomainResource"))
throw new Exception("unknown resource type " + p.getType());
sp.setType(getSearchParamType(spd.getType()));
if (sp.getType() == SearchParamType.REFERENCE && spd.isHierarchy()) {
sp.addModifier(SearchParameter.SearchModifierCode.BELOW);
sp.addModifier(SearchParameter.SearchModifierCode.ABOVE);
}
if (shared) {
sp.setDescription("Multiple Resources: \r\n\r\n* [" + rn + "](" + rn.toLowerCase() + ".html): " + spd.getDescription() + "\r\n");
} else
sp.setDescription(preProcessMarkdown(spd.getDescription(), "Search Description"));
if (!Utilities.noString(spd.getExpression()))
sp.setExpression(spd.getExpression());
// addModifiers(sp);
addComparators(sp);
String xpath = Utilities.noString(spd.getXPath()) ? new XPathQueryGenerator(this.definitions, null, null).generateXpath(spd.getPaths(), rn) : spd.getXPath();
if (xpath != null) {
if (xpath.contains("[x]"))
xpath = convertToXpath(xpath);
sp.setXpath(xpath);
sp.setXpathUsage(spd.getxPathUsage());
}
if (sp.getType() == SearchParamType.COMPOSITE) {
for (CompositeDefinition cs : spd.getComposites()) {
SearchParameterDefn cspd = findSearchParameter(rd, cs.getDefinition());
if (cspd != null)
sp.addComponent().setExpression(cs.getExpression()).setDefinition(cspd.getUrl());
else
sp.addComponent().setExpression(cs.getExpression()).setDefinition("http://hl7.org/fhir/SearchParameter/" + rn + "-" + cs.getDefinition());
}
sp.setMultipleOr(false);
}
sp.addBase(p.getType());
} else {
if (sp.getType() != getSearchParamType(spd.getType()))
throw new FHIRException("Type mismatch on common parameter: expected " + sp.getType().toCode() + " but found " + getSearchParamType(spd.getType()).toCode());
if (!sp.getDescription().contains("[" + rn + "](" + rn.toLowerCase() + ".html)"))
sp.setDescription(sp.getDescription() + "* [" + rn + "](" + rn.toLowerCase() + ".html): " + spd.getDescription() + "\r\n");
// ext.addExtension("description", new MarkdownType(spd.getDescription()));
if (!Utilities.noString(spd.getExpression()) && !sp.getExpression().contains(spd.getExpression()))
sp.setExpression(sp.getExpression() + " | " + spd.getExpression());
String xpath = new XPathQueryGenerator(this.definitions, null, null).generateXpath(spd.getPaths(), rn);
if (xpath != null) {
if (xpath.contains("[x]"))
xpath = convertToXpath(xpath);
if (sp.getXpath() != null && !sp.getXpath().contains(xpath))
sp.setXpath(sp.getXpath() + " | " + xpath);
if (sp.getXpathUsage() != spd.getxPathUsage())
throw new FHIRException("Usage mismatch on common parameter: expected " + sp.getXpathUsage().toCode() + " but found " + spd.getxPathUsage().toCode());
}
boolean found = false;
for (CodeType ct : sp.getBase()) found = found || p.getType().equals(ct.asStringValue());
if (!found)
sp.addBase(p.getType());
}
spd.setUrl(sp.getUrl());
for (String target : spd.getWorkingTargets()) {
if ("Any".equals(target) == true) {
for (String resourceName : definitions.sortedResourceNames()) {
boolean found = false;
for (CodeType st : sp.getTarget()) found = found || st.asStringValue().equals(resourceName);
if (!found)
sp.addTarget(resourceName);
}
} else {
boolean found = false;
for (CodeType st : sp.getTarget()) found = found || st.asStringValue().equals(target);
if (!found)
sp.addTarget(target);
}
}
return sp;
}
use of org.hl7.fhir.r5.model.MarkdownType in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MDMMessageTest method test_mdm_ORDER_with_OBXnotTX.
@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void test_mdm_ORDER_with_OBXnotTX(String message) throws IOException {
// Also check NTE working for MDM messages.
String hl7message = "MSH|^~\\&|HNAM|W|RAD_IMAGING_REPORT|W|20180118111520||" + message + "|<MESSAGEID>|P|2.6\r" + "EVN||20150502090000|\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||O||||||||||||||||||||||||||||||||||||||||||199501102300\r" + "ORC|NW|622470H432|||||^^^^^R||||||||||||||\r" + "OBR|1|622470H432|102397CE432|||20170725143849|20180102|||||||||||||||||RAD|O||^^^^^R||||REASON_ID_1^REASON_TEXT_1||||\r" + // ServiceRequest NTE has a practitioner reference in NTE.5
"NTE|1|O|TEST ORC/OBR NOTE AA line 1||Pract1ID^Pract1Last^Pract1First|\n" + "NTE|2|O|TEST NOTE AA line 2|\n" + "TXA|1|HP^History and physical examination|TX||||201801171442||||||||||||AV|||||\r" + "OBX|1|NM|Most Current Weight^Most current measured weight (actual)||90|kg\r" + // Observation NTE has a practitioner reference in second NTE.5. Annotation uses the first valid NTE.5
"NTE|1|L|TEST OBX NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2||Pract2ID^Pract2Last^Pract2First|\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Check for the expected resources
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
// from EVN, PV1
assertThat(encounterResource).hasSize(1);
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
// from PID
assertThat(patientResource).hasSize(1);
List<Resource> serviceRequestResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
// from ORC, OBR
assertThat(serviceRequestResource).hasSize(1);
// Light check that ServiceRequest contains NTE for ORC/OBR; Deep check of NTE in Hl7NoteFHIRConverterTest.
ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestResource.get(0), ResourceUtils.context);
assertThat(serviceRequest.hasNote()).isTrue();
assertThat(serviceRequest.getNote()).hasSize(1);
// NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
// Must use getTextElement().getValueAsString() to see untrimmed contents.
assertThat(serviceRequest.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST ORC/OBR NOTE AA line 1 \nTEST NOTE AA line 2");
assertThat(serviceRequest.getNote().get(0).hasAuthorReference()).isTrue();
List<Resource> documentReferenceResource = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
// from TXA
assertThat(documentReferenceResource).hasSize(1);
List<Resource> observationResources = ResourceUtils.getResourceList(e, ResourceType.Observation);
// from OBX(not type TX)
assertThat(observationResources).hasSize(1);
// Light check that Observation contains NTE for OBX; Deep check of NTE in Hl7NoteFHIRConverterTest.
Observation observation = ResourceUtils.getResourceObservation(observationResources.get(0), ResourceUtils.context);
// Validate the note contents and reference existance.
assertThat(observation.hasNote()).isTrue();
assertThat(observation.getNote()).hasSize(1);
// NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
// Must use getTextElement().getValueAsString() to see untrimmed contents.
assertThat(observation.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBX NOTE BB line 1 \nTEST NOTE BB line 2");
assertThat(observation.getNote().get(0).hasAuthorReference()).isTrue();
// Two Practitioners, one for the serviceRequest, one for the Observation
List<Resource> practitioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
// from NTE.4 references
assertThat(practitioners).hasSize(2);
// Confirm that no extra resources are created
assertThat(e.size()).isEqualTo(7);
}
use of org.hl7.fhir.r5.model.MarkdownType in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7NoteFHIRConverterTest method testNoteCreationMutiplePPR.
// Test that multiple problems (PRB) each with multiple notes (NTE) are associated with the correct NTE / PRB
// and that there is no "bleed"
@Test
void testNoteCreationMutiplePPR() throws IOException {
// TODO: Add PC2 and PC3 tests in future
String message = "PPR^PC1";
String hl7message = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|" + message + "|1|P^I|2.6||||||ASCII||\n" + "PID|||555444222111^^^MPI&GenHosp&L^MR||james^anderson|||M||||||||||||||\n" + "PV1||I|||||||||||||||||1400|||||||||||||||||||||||||199501102300\n" + "PRB|AD|200603150625|aortic stenosis|53692||2||200603150625\n" + "NTE|1|O|TEST PRBa NOTE AA line 1|\n" + "NTE|2|O|TEST NOTE AA line 2|\n" + "NTE|3|O|TEST NOTE AA line 3|\n" + "OBX|1|NM|17985^GLYCOHEMOGLOBIN HGB A1C^LRR^^^^^^GLYCOHEMOGLOBIN HGB A1C||5.6|%|<6.0||||F||||||||||||||\n" + "NTE|1|L|TEST OBXb NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2|\n" + "NTE|3|L|TEST NOTE BB line 3|\n" + "OBX|2|NM|17853^MEAN BLOOD GLUCOSE^LRR^^^^^^MEAN BLOOD GLUCOSE||114.02|mg/dL|||||F||||||||||||||\n" + "NTE|1|L|TEST OBXc NOTE CC line 1|\n" + "NTE|2|L|TEST NOTE CC line 2|\n" + "NTE|3|L|TEST NOTE CC line 3|\n" + "PRB|AD|200603150625|I47.2^Ventricular tachycardia^ICD-10-CM|53692||2||200603150625\n" + "NTE|1|O|TEST PRBd NOTE DD line 1|\n" + "NTE|2|O|TEST NOTE DD line 2|\n" + "NTE|3|O|TEST NOTE DD line 3|\n" + "OBX|1|NM|8595^BP Mean|1|88|MM HG|||||F|||20180520230000|||\n" + "NTE|1|L|TEST OBXe NOTE EE line 1|\n" + "NTE|2|L|TEST NOTE EE line 2|\n" + "NTE|3|L|TEST NOTE EE line 3|\n" + "OBX|2|NM|7302^Resp Rate|1|19||||||F|||20180520230000|||\n" + // Single NTE to ensure it is created correctly
"NTE|1|L|TEST OBXf NOTE FF line 1|\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patients).hasSize(1);
// Two Conditions from two PRBs. One has "... stenosis" and notes AA, One has "... Tachycardia" and notes DD
List<Resource> conditions = ResourceUtils.getResourceList(e, ResourceType.Condition);
assertThat(conditions).hasSize(2);
Condition condStenosis = ResourceUtils.getResourceCondition(conditions.get(0), ResourceUtils.context);
Condition condTachy = ResourceUtils.getResourceCondition(conditions.get(1), ResourceUtils.context);
// Figure out which is first and reassign if needed for testing
if (!condStenosis.getCode().getCodingFirstRep().getCode().contains("aortic stenosis")) {
Condition temp = condStenosis;
condStenosis = condTachy;
condTachy = temp;
}
// Test the conditions have the correct NTE's associated and have correct content.
// NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
// Must use getTextElement().getValueAsString() to see untrimmed contents.
assertThat(condStenosis.hasNote()).isTrue();
assertThat(condStenosis.getNote()).hasSize(1);
assertThat(condStenosis.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST PRBa NOTE AA line 1 \nTEST NOTE AA line 2 \nTEST NOTE AA line 3");
assertThat(condTachy.hasNote()).isTrue();
assertThat(condTachy.getNote()).hasSize(1);
assertThat(condTachy.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST PRBd NOTE DD line 1 \nTEST NOTE DD line 2 \nTEST NOTE DD line 3");
// Four observations. Two associated with the first problem and two with the second
// This map tells us what Annotation text is associated with an Observation code
Map<String, String> matchObsCodeToNotes = new HashMap<>();
matchObsCodeToNotes.put("17985", "TEST OBXb NOTE BB line 1 \nTEST NOTE BB line 2 \nTEST NOTE BB line 3");
matchObsCodeToNotes.put("17853", "TEST OBXc NOTE CC line 1 \nTEST NOTE CC line 2 \nTEST NOTE CC line 3");
matchObsCodeToNotes.put("8595", "TEST OBXe NOTE EE line 1 \nTEST NOTE EE line 2 \nTEST NOTE EE line 3");
matchObsCodeToNotes.put("7302", "TEST OBXf NOTE FF line 1");
// This map tells us what Parent should be associated with an Observation code
Map<String, String> matchObsCodeToParent = new HashMap<>();
matchObsCodeToParent.put("17985", "aortic stenosis");
matchObsCodeToParent.put("17853", "aortic stenosis");
matchObsCodeToParent.put("8595", "I47.2");
matchObsCodeToParent.put("7302", "I47.2");
List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
assertThat(observations).hasSize(4);
int observationsVerified = 0;
// For the list of Conditions
for (int condIndex = 0; condIndex < conditions.size(); condIndex++) {
// condIndex is index for condition
// Get the list of Observation references
Condition cond = ResourceUtils.getResourceCondition(conditions.get(condIndex), ResourceUtils.context);
List<ConditionEvidenceComponent> evidences = cond.getEvidence();
for (int evidenceIndex = 0; evidenceIndex < evidences.size(); evidenceIndex++) {
// Get the evidence Observation reference
String obsReferenceId = evidences.get(evidenceIndex).getDetailFirstRep().getReference();
// Find the referenced observation
for (int obsIndex = 0; obsIndex < observations.size(); obsIndex++) {
// If the Id's match
if (obsReferenceId.contains(observations.get(obsIndex).getId())) {
// Check the contents and the parent
Observation obs = ResourceUtils.getResourceObservation(observations.get(obsIndex), ResourceUtils.context);
String code = obs.getCode().getCodingFirstRep().getCode().toString();
// The Annotation text should match the mapped text for this key
assertThat(obs.getNoteFirstRep().getText()).hasToString(matchObsCodeToNotes.get(code));
// The parent Condition code.coding.code should match the expected mapped code for this key
assertThat(cond.getCode().getCodingFirstRep().getCode()).hasToString(matchObsCodeToParent.get(code));
observationsVerified++;
break;
}
}
}
}
// This confirms ALL of the observations were checked.
assertThat(observationsVerified).isEqualTo(4);
}
use of org.hl7.fhir.r5.model.MarkdownType in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7NoteFHIRConverterTest method testMedicationRequestNoteCreation.
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@ParameterizedTest
@MethodSource("parmsTestMedicationRequestNoteCreation")
void testMedicationRequestNoteCreation(String message, String medicalRequestSegments) {
// Minimal valid ORC message. Requires RXO and RXR segments.
String hl7message = "MSH|^~\\&||||IBM|20210101000000||" + message + "|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP|1234|1234|0827||||||||||||||||||||\n" + // May be RXO or RXO+RXE values from parmsTestMedicationRequestNoteCreation
medicalRequestSegments + "NTE|1|O|TEST MedReq NOTE AA line 1||Pract1ID^Pract1Last^Pract1First|\n" + "NTE|2|O|TEST NOTE AA line 2|\n" + "NTE|3|O|TEST NOTE AA line 3|\n" + "OBX|1|NM|17985^GLYCOHEMOGLOBIN HGB A1C^LRR^^^^^^GLYCOHEMOGLOBIN HGB A1C||5.6|%|<6.0||||F||||||||||||||\n" + // GLYCOHEMOGLOBIN Observation NTE has a practitioner reference in NTE.5. Note in second NTE. The first valid NTE.5 is used.
"NTE|1|L|TEST OBXa NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2||Pract2ID^Pract2Last^Pract2First|\n" + "NTE|3|L|TEST NOTE BB line 3|\n" + "OBX|2|NM|17853^MEAN BLOOD GLUCOSE^LRR^^^^^^MEAN BLOOD GLUCOSE||114.02|mg/dL|||||F||||||||||||||\n" + // Glucose Observation NTE has no practitioner reference in NTE.5
"NTE|1|L|TEST OBXb NOTE CC line 1|\n" + "NTE|2|L|TEST NOTE CC line 2|\n" + // Test that blank lines are preserved.
"NTE|3|L| |\n" + "NTE|4|L|TEST NOTE CC line 4|\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Expect MedicationRequest containing NTE for RXO or RXE
List<Resource> medicationRequests = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequests).hasSize(1);
MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequests.get(0), ResourceUtils.context);
assertThat(medicationRequest.hasNote()).isTrue();
assertThat(medicationRequest.getNote()).hasSize(1);
// NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
// Must use getTextElement().getValueAsString() to see untrimmed contents.
assertThat(medicationRequest.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST MedReq NOTE AA line 1 \nTEST NOTE AA line 2 \nTEST NOTE AA line 3");
assertThat(medicationRequest.getNote().get(0).hasAuthorReference()).isTrue();
String practitionerServReqRefId = medicationRequest.getNote().get(0).getAuthorReference().getReference();
// Two observations. One has GLYCOHEMOGLOBIN and notes BB, One has GLUCOSE and notes CC
List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
// Should be 2 for ORU and ORM
assertThat(observations).hasSize(2);
Observation obsGlucose = ResourceUtils.getResourceObservation(observations.get(0), ResourceUtils.context);
Observation obsHemoglobin = ResourceUtils.getResourceObservation(observations.get(1), ResourceUtils.context);
// Figure out which is first and reassign if needed for testing
if (obsGlucose.getCode().getText() != "MEAN BLOOD GLUCOSE") {
Observation temp = obsGlucose;
obsGlucose = obsHemoglobin;
obsHemoglobin = temp;
}
// Validate the note contents and references
assertThat(obsHemoglobin.hasNote()).isTrue();
assertThat(obsHemoglobin.getNote()).hasSize(1);
assertThat(obsHemoglobin.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBXa NOTE BB line 1 \nTEST NOTE BB line 2 \nTEST NOTE BB line 3");
assertThat(obsHemoglobin.getNote().get(0).hasAuthorReference()).isTrue();
String practitionerObsHemoglobinRefId = obsHemoglobin.getNote().get(0).getAuthorReference().getReference();
assertThat(obsGlucose.hasNote()).isTrue();
assertThat(obsGlucose.getNote()).hasSize(1);
assertThat(obsGlucose.getNote().get(0).getTextElement().getValueAsString()).isEqualTo(// Test that blank lines are preserved.
"TEST OBXb NOTE CC line 1 \nTEST NOTE CC line 2 \n \nTEST NOTE CC line 4");
assertThat(obsGlucose.getNote().get(0).hasAuthorReference()).isFalse();
// Two Practitioners, one for the serviceRequest, one for the GLYCOHEMOGLOBIN Observation
List<Resource> practitioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
assertThat(practitioners).hasSize(2);
Practitioner practitionerServReq = ResourceUtils.getResourcePractitioner(practitioners.get(0), ResourceUtils.context);
Practitioner practitionerObsHemoglobin = ResourceUtils.getResourcePractitioner(practitioners.get(1), ResourceUtils.context);
// Adjust to correct practitioner if needed
if (!practitionerServReq.getIdentifierFirstRep().getValue().contentEquals("Pract1ID")) {
Practitioner temp = practitionerObsHemoglobin;
practitionerObsHemoglobin = practitionerServReq;
practitionerServReq = temp;
}
// Check the values for the Practitioners and validate match to references.
assertThat(practitionerServReq.getIdentifier()).hasSize(1);
assertThat(practitionerServReq.getIdentifierFirstRep().getValue()).isEqualTo("Pract1ID");
assertThat(practitionerServReq.getName()).hasSize(1);
assertThat(practitionerServReq.getNameFirstRep().getText()).isEqualTo("Pract1First Pract1Last");
// Check the cross-reference
assertThat(practitionerServReq.getId()).isEqualTo(practitionerServReqRefId);
// Sanity check to confirm data corruption in meta content has not returned.
CodeableConcept ccSourceEventTrigger = (CodeableConcept) practitionerServReq.getMeta().getExtensionByUrl("http://ibm.com/fhir/cdm/StructureDefinition/source-event-trigger").getValue();
assertThat(ccSourceEventTrigger.hasText()).isFalse();
assertThat(practitionerObsHemoglobin.getIdentifier()).hasSize(1);
assertThat(practitionerObsHemoglobin.getIdentifierFirstRep().getValue()).isEqualTo("Pract2ID");
assertThat(practitionerObsHemoglobin.getName()).hasSize(1);
assertThat(practitionerObsHemoglobin.getNameFirstRep().getText()).isEqualTo("Pract2First Pract2Last");
// Check the cross-reference
assertThat(practitionerObsHemoglobin.getId()).isEqualTo(practitionerObsHemoglobinRefId);
}
Aggregations