Search in sources :

Example 31 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method createPatient.

@Test
public void createPatient() {
    account.setId("userId");
    account.setFirstName("Test");
    account.setLastName("User");
    account.setEmail(EMAIL);
    account.setEmailVerified(true);
    account.setPhone(PHONE);
    account.setPhoneVerified(true);
    account.setAttributes(new ImmutableMap.Builder<String, String>().put("address1", "123 Sesame Street").put("address2", "Apt. 6").put("city", "Seattle").put("dob", "1980-08-10").put("gender", "female").put("state", "WA").put("zip_code", "10001").put("home_phone", PHONE.getNumber()).build());
    Patient patient = controller.createPatient(account);
    assertTrue(patient.getActive());
    assertEquals(patient.getIdentifier().get(0).getValue(), TEST_USER_ID);
    assertEquals(patient.getIdentifier().get(0).getSystem(), USER_ID_VALUE_NS);
    assertEquals(patient.getName().get(0).getGivenAsSingleString(), "Test");
    assertEquals(patient.getName().get(0).getFamily(), "User");
    assertEquals(patient.getMeta().getTag().get(0).getSystem(), "source");
    assertEquals(patient.getMeta().getTag().get(0).getCode(), "sage");
    assertEquals(patient.getGender().name(), "FEMALE");
    assertEquals(LocalDate.fromDateFields(patient.getBirthDate()).toString(), "1980-08-10");
    assertEquals(patient.getTelecom().get(0).getValue(), PHONE.getNumber());
    assertEquals(patient.getTelecom().get(0).getSystem().name(), "PHONE");
    assertEquals(patient.getTelecom().get(1).getValue(), PHONE.getNumber());
    assertEquals(patient.getTelecom().get(1).getSystem().name(), "SMS");
    assertEquals(patient.getTelecom().get(2).getValue(), EMAIL);
    assertEquals(patient.getTelecom().get(2).getSystem().name(), "EMAIL");
    Address address = patient.getAddress().get(0);
    assertEquals(address.getLine().get(0).getValue(), "123 Sesame Street");
    assertEquals(address.getLine().get(1).getValue(), "Apt. 6");
    assertEquals(address.getCity(), "Seattle");
    assertEquals(address.getState(), "WA");
    assertEquals(address.getPostalCode(), "10001");
}
Also used : Address(org.hl7.fhir.dstu3.model.Address) Patient(org.hl7.fhir.dstu3.model.Patient) Test(org.testng.annotations.Test)

Example 32 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project quality-measure-and-cohort-service by Alvearie.

the class PathCaptureContext method reportProperty.

public void reportProperty(Property elm) {
    // Log guarding to prevent some of the parameter resolution logic from getting called unnecessarily
    if (LOG.isTraceEnabled()) {
        LOG.trace("Property {} source {}", elm.getPath(), elm.getSource() != null ? elm.getSource().getClass().getSimpleName() : null);
    }
    Set<QName> modelTypeNames = null;
    if (elm.getScope() != null || elm.getSource() instanceof AliasRef) {
        String aliasName = (elm.getScope() != null) ? elm.getScope() : ((AliasRef) elm.getSource()).getName();
        QueryAliasContext aliasContext = getCurrentQueryContext().resolveAlias(aliasName);
        if (aliasContext == null) {
            aliasContext = getCurrentExpressionContext().resolveAlias(aliasName);
        }
        modelTypeNames = ElmUtils.getModelTypeNames(aliasContext.getAliasedQuerySource().getExpression());
    } else if (elm.getSource() instanceof QueryLetRef) {
        String letName = ((QueryLetRef) elm.getSource()).getName();
        QueryLetContext letContext = getCurrentQueryContext().resolveLet(letName);
        if (letContext == null) {
            letContext = getCurrentExpressionContext().resolveLet(letName);
        }
        modelTypeNames = ElmUtils.getModelTypeNames(letContext.getLetClause().getExpression());
    } else {
        // There are times when the scope is null. I've noticed this particularly when referencing properties
        // of another expression result
        modelTypeNames = ElmUtils.getModelTypeNames(elm.getSource());
    }
    LOG.trace("ModelTypeNames {}", modelTypeNames);
    if (modelTypeNames != null) {
        for (QName qname : modelTypeNames) {
            pathsByQName.computeIfAbsent(qname, key -> new HashSet<>()).add(elm.getPath());
        }
    }
}
Also used : Property(org.hl7.elm.r1.Property) Logger(org.slf4j.Logger) VersionedIdentifier(org.hl7.elm.r1.VersionedIdentifier) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) UsingDef(org.hl7.elm.r1.UsingDef) HashMap(java.util.HashMap) Deque(java.util.Deque) HashSet(java.util.HashSet) AliasRef(org.hl7.elm.r1.AliasRef) Retrieve(org.hl7.elm.r1.Retrieve) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) QueryLetRef(org.hl7.elm.r1.QueryLetRef) QName(javax.xml.namespace.QName) ArrayDeque(java.util.ArrayDeque) ByColumn(org.hl7.elm.r1.ByColumn) ExpressionDef(org.hl7.elm.r1.ExpressionDef) AliasRef(org.hl7.elm.r1.AliasRef) QName(javax.xml.namespace.QName) QueryLetRef(org.hl7.elm.r1.QueryLetRef) HashSet(java.util.HashSet)

Example 33 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project integration-adaptor-111 by nhsconnect.

the class MessageHeaderServiceTest method shouldCreateMessageHeader.

@Test
public void shouldCreateMessageHeader() {
    ItkReportHeader itkReportHeader = new ItkReportHeader();
    itkReportHeader.setSpecKey(SPECIFICATION_KEY);
    itkReportHeader.setSpecVal(SPECIFICATION_VALUE);
    itkReportHeader.setAddressList(Arrays.asList(ADDRESS));
    MessageHeader messageHeader = messageHeaderService.createMessageHeader(itkReportHeader, MESSAGEID, EFFECTIVE_TIME);
    assertThat(messageHeader.getId()).isEqualTo(MESSAGEID);
    Coding event = messageHeader.getEvent();
    assertThat(event.getSystem()).isEqualTo(MessageHeaderEvent.SYSTEM);
    assertThat(event.getCode()).isEqualTo(DISCHARGE_DETAILS.getCode());
    assertThat(event.getDisplay()).isEqualTo(DISCHARGE_DETAILS.getDisplay());
    MessageSourceComponent source = messageHeader.getSource();
    assertThat(source.getName()).isEqualTo(MESSAGE_SOURCE_NAME);
    assertThat(source.getEndpoint()).isEqualTo(ENDPOINT);
    assertThat(messageHeader.getReason().getCodingFirstRep().getSystem()).isEqualTo(SPECIFICATION_KEY);
    assertThat(messageHeader.getReason().getCodingFirstRep().getCode()).isEqualTo(SPECIFICATION_VALUE);
    assertThat(messageHeader.getDestinationFirstRep().getEndpoint()).isEqualTo(ADDRESS);
    assertThat(messageHeader.getTimestampElement()).isEqualToComparingFieldByField(DateUtil.parseToInstantType(EFFECTIVE_TIME));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ItkReportHeader(uk.nhs.adaptors.oneoneone.cda.report.controller.utils.ItkReportHeader) MessageSourceComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent) MessageHeader(org.hl7.fhir.dstu3.model.MessageHeader) Test(org.junit.jupiter.api.Test)

Example 34 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project integration-adaptor-111 by nhsconnect.

the class MessageHeaderService method getSource.

private MessageSourceComponent getSource() {
    MessageSourceComponent source = new MessageSourceComponent();
    source.setName(MESSAGE_SOURCE_NAME);
    source.setEndpoint(soapProperties.getSendTo());
    return source;
}
Also used : MessageSourceComponent(org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent)

Example 35 with Source

use of org.hl7.fhir.utilities.validation.ValidationMessage.Source in project org.hl7.fhir.core by hapifhir.

the class R2R3ConversionManager method convertToR3.

private void convertToR3(InputStream source, OutputStream dest, FhirFormat format) throws FHIRException, IOException {
    org.hl7.fhir.dstu3.elementmodel.Element r2 = new org.hl7.fhir.dstu3.elementmodel.XmlParser(contextR2).parse(source);
    StructureMap map = library.get("http://hl7.org/fhir/StructureMap/" + r2.fhirType() + "2to3");
    if (map == null)
        throw new FHIRException("No Map Found from R2 to R3 for " + r2.fhirType());
    String tn = smu3.getTargetType(map).getType();
    Resource r3 = ResourceFactory.createResource(tn);
    smu3.transform(new TransformContextR2R3(contextR3, r2.getChildValue("id")), r2, map, r3);
    FormatUtilities.makeParser(format).setOutputStyle(style).compose(dest, r3);
}
Also used : FHIRException(org.hl7.fhir.exceptions.FHIRException)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)125 FileInputStream (java.io.FileInputStream)59 FileOutputStream (java.io.FileOutputStream)55 IOException (java.io.IOException)55 ArrayList (java.util.ArrayList)48 File (java.io.File)45 CSFileInputStream (org.hl7.fhir.utilities.CSFileInputStream)45 TextFile (org.hl7.fhir.utilities.TextFile)41 CSFile (org.hl7.fhir.utilities.CSFile)35 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)35 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)30 XmlParser (org.hl7.fhir.r5.formats.XmlParser)28 Date (java.util.Date)27 HashMap (java.util.HashMap)26 Reference (org.hl7.fhir.r4.model.Reference)26 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)24 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)24 Coding (org.hl7.fhir.r4.model.Coding)24 JsonObject (com.google.gson.JsonObject)22 NotImplementedException (org.apache.commons.lang3.NotImplementedException)22