use of org.hl7.fhir.r4b.model.MarkdownType in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7NoteFHIRConverterTest method testNoteCreationServiceRequestMutipleOBX.
// 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("provideParmsForNoteCreationServiceRequestMutipleOBX")
void testNoteCreationServiceRequestMutipleOBX(String message, int numExpectedDiagnosticReports) {
String hl7ORU = "MSH|^~\\&|||||20180924152907||" + message + "|213|T|2.3.1|||||||||||\n" + "PID|||Pract1ID^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // "NTE|1|O|TEST NOTE DD line 1|\n" + "NTE|2|O|TEST NOTE DD line 2 |\n" + "NTE|3|O|TEST NOTE D line 3|\n"
"PV1|1|I||||||||||||||||||||||||||||||||||||||||||20180924152707|\n" + "ORC|RE|248648498^|248648498^|ML18267-C00001^Beaker|||||||||||||||||||||||||||\n" + "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C||||||||||||||||||||||||||||||||||||\n" + // 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" + "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 valied 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, hl7ORU);
List<Resource> diagnosticReports = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
// DiagnosticReport expected for ORU, but not for ORM
// From the OBR in the ORU test case
assertThat(diagnosticReports).hasSize(numExpectedDiagnosticReports);
// One ServiceRequest contains NTE for ORC/OBR
List<Resource> serviceRequests = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
assertThat(serviceRequests).hasSize(1);
ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequests.get(0), ResourceUtils.context);
assertThat(serviceRequest.hasNote()).isTrue();
assertThat(serviceRequest.getNote()).hasSize(1);
// Processing adds " \n" two spaces and a line feed between each line.
// 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 \nTEST NOTE AA line 3");
assertThat(serviceRequest.getNote().get(0).hasAuthorReference()).isTrue();
String practitionerServReqRefId = serviceRequest.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);
}
use of org.hl7.fhir.r4b.model.MarkdownType in project org.hl7.fhir.core by hapifhir.
the class JsonParser method composeType.
protected void composeType(String prefix, Type type) throws IOException {
if (type == null)
;
else if (type instanceof Age)
composeAge(prefix + "Age", (Age) type);
else if (type instanceof Count)
composeCount(prefix + "Count", (Count) type);
else if (type instanceof Money)
composeMoney(prefix + "Money", (Money) type);
else if (type instanceof Distance)
composeDistance(prefix + "Distance", (Distance) type);
else if (type instanceof Duration)
composeDuration(prefix + "Duration", (Duration) type);
else if (type instanceof SimpleQuantity)
composeSimpleQuantity(prefix + "SimpleQuantity", (SimpleQuantity) type);
else if (type instanceof Period)
composePeriod(prefix + "Period", (Period) type);
else if (type instanceof Coding)
composeCoding(prefix + "Coding", (Coding) type);
else if (type instanceof Range)
composeRange(prefix + "Range", (Range) type);
else if (type instanceof Quantity)
composeQuantity(prefix + "Quantity", (Quantity) type);
else if (type instanceof Attachment)
composeAttachment(prefix + "Attachment", (Attachment) type);
else if (type instanceof Ratio)
composeRatio(prefix + "Ratio", (Ratio) type);
else if (type instanceof Annotation)
composeAnnotation(prefix + "Annotation", (Annotation) type);
else if (type instanceof SampledData)
composeSampledData(prefix + "SampledData", (SampledData) type);
else if (type instanceof Reference)
composeReference(prefix + "Reference", (Reference) type);
else if (type instanceof CodeableConcept)
composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
else if (type instanceof Identifier)
composeIdentifier(prefix + "Identifier", (Identifier) type);
else if (type instanceof Signature)
composeSignature(prefix + "Signature", (Signature) type);
else if (type instanceof TriggerDefinition)
composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
else if (type instanceof ElementDefinition)
composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
else if (type instanceof Timing)
composeTiming(prefix + "Timing", (Timing) type);
else if (type instanceof ModuleMetadata)
composeModuleMetadata(prefix + "ModuleMetadata", (ModuleMetadata) type);
else if (type instanceof ActionDefinition)
composeActionDefinition(prefix + "ActionDefinition", (ActionDefinition) type);
else if (type instanceof Address)
composeAddress(prefix + "Address", (Address) type);
else if (type instanceof HumanName)
composeHumanName(prefix + "HumanName", (HumanName) type);
else if (type instanceof DataRequirement)
composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
else if (type instanceof Meta)
composeMeta(prefix + "Meta", (Meta) type);
else if (type instanceof ParameterDefinition)
composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
else if (type instanceof ContactPoint)
composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
else if (type instanceof MarkdownType) {
composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
} else if (type instanceof UnsignedIntType) {
composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
} else if (type instanceof CodeType) {
composeCodeCore(prefix + "Code", (CodeType) type, false);
composeCodeExtras(prefix + "Code", (CodeType) type, false);
} else if (type instanceof IdType) {
composeIdCore(prefix + "Id", (IdType) type, false);
composeIdExtras(prefix + "Id", (IdType) type, false);
} else if (type instanceof OidType) {
composeOidCore(prefix + "Oid", (OidType) type, false);
composeOidExtras(prefix + "Oid", (OidType) type, false);
} else if (type instanceof PositiveIntType) {
composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
} else if (type instanceof UuidType) {
composeUuidCore(prefix + "Uuid", (UuidType) type, false);
composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
} else if (type instanceof IntegerType) {
composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
} else if (type instanceof DateTimeType) {
composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
} else if (type instanceof DateType) {
composeDateCore(prefix + "Date", (DateType) type, false);
composeDateExtras(prefix + "Date", (DateType) type, false);
} else if (type instanceof DecimalType) {
composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
} else if (type instanceof UriType) {
composeUriCore(prefix + "Uri", (UriType) type, false);
composeUriExtras(prefix + "Uri", (UriType) type, false);
} else if (type instanceof Base64BinaryType) {
composeBase64BinaryCore(prefix + "Base64Binary", (Base64BinaryType) type, false);
composeBase64BinaryExtras(prefix + "Base64Binary", (Base64BinaryType) type, false);
} else if (type instanceof TimeType) {
composeTimeCore(prefix + "Time", (TimeType) type, false);
composeTimeExtras(prefix + "Time", (TimeType) type, false);
} else if (type instanceof StringType) {
composeStringCore(prefix + "String", (StringType) type, false);
composeStringExtras(prefix + "String", (StringType) type, false);
} else if (type instanceof BooleanType) {
composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
} else if (type instanceof InstantType) {
composeInstantCore(prefix + "Instant", (InstantType) type, false);
composeInstantExtras(prefix + "Instant", (InstantType) type, false);
} else
throw new Error("Unhandled type");
}
use of org.hl7.fhir.r4b.model.MarkdownType in project org.hl7.fhir.core by hapifhir.
the class SearchParameter method setProperty.
@Override
public Base setProperty(String name, Base value) throws FHIRException {
if (name.equals("url")) {
// UriType
this.url = castToUri(value);
} else if (name.equals("version")) {
// StringType
this.version = castToString(value);
} else if (name.equals("name")) {
// StringType
this.name = castToString(value);
} else if (name.equals("status")) {
value = new PublicationStatusEnumFactory().fromType(castToCode(value));
// Enumeration<PublicationStatus>
this.status = (Enumeration) value;
} else if (name.equals("experimental")) {
// BooleanType
this.experimental = castToBoolean(value);
} else if (name.equals("date")) {
// DateTimeType
this.date = castToDateTime(value);
} else if (name.equals("publisher")) {
// StringType
this.publisher = castToString(value);
} else if (name.equals("contact")) {
this.getContact().add(castToContactDetail(value));
} else if (name.equals("useContext")) {
this.getUseContext().add(castToUsageContext(value));
} else if (name.equals("jurisdiction")) {
this.getJurisdiction().add(castToCodeableConcept(value));
} else if (name.equals("purpose")) {
// MarkdownType
this.purpose = castToMarkdown(value);
} else if (name.equals("code")) {
// CodeType
this.code = castToCode(value);
} else if (name.equals("base")) {
this.getBase().add(castToCode(value));
} else if (name.equals("type")) {
value = new SearchParamTypeEnumFactory().fromType(castToCode(value));
// Enumeration<SearchParamType>
this.type = (Enumeration) value;
} else if (name.equals("derivedFrom")) {
// UriType
this.derivedFrom = castToUri(value);
} else if (name.equals("description")) {
// MarkdownType
this.description = castToMarkdown(value);
} else if (name.equals("expression")) {
// StringType
this.expression = castToString(value);
} else if (name.equals("xpath")) {
// StringType
this.xpath = castToString(value);
} else if (name.equals("xpathUsage")) {
value = new XPathUsageTypeEnumFactory().fromType(castToCode(value));
// Enumeration<XPathUsageType>
this.xpathUsage = (Enumeration) value;
} else if (name.equals("target")) {
this.getTarget().add(castToCode(value));
} else if (name.equals("comparator")) {
value = new SearchComparatorEnumFactory().fromType(castToCode(value));
this.getComparator().add((Enumeration) value);
} else if (name.equals("modifier")) {
value = new SearchModifierCodeEnumFactory().fromType(castToCode(value));
this.getModifier().add((Enumeration) value);
} else if (name.equals("chain")) {
this.getChain().add(castToString(value));
} else if (name.equals("component")) {
this.getComponent().add((SearchParameterComponentComponent) value);
} else
return super.setProperty(name, value);
return value;
}
use of org.hl7.fhir.r4b.model.MarkdownType in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeMarkdown.
protected void composeMarkdown(Complex parent, String parentType, String name, MarkdownType value, int index) {
if (value == null)
return;
Complex t = parent.predicate("fhir:" + parentType + "." + name);
t.predicate("fhir:value", ttlLiteral(value.asStringValue()));
composeElement(t, parentType, name, value, index);
}
use of org.hl7.fhir.r4b.model.MarkdownType in project org.hl7.fhir.core by hapifhir.
the class MarkdownTypeNullTest method equalsShallow.
@Test
@DisplayName("Test null value equalsShallow()")
void equalsShallow() {
MarkdownType nullMarkdown = new MarkdownType();
MarkdownType validMarkdown = new MarkdownType("__MARKDOWN__");
Assertions.assertFalse(nullMarkdown.equalsShallow(validMarkdown));
}
Aggregations