Search in sources :

Example 26 with Time

use of org.hl7.elm.r1.Time in project summary-care-record-api by NHSDigital.

the class FindingMapper method mapPerformer.

private void mapPerformer(List<Resource> resources, Encounter encounter, Node performer) {
    DateTimeType time = parseDate(xmlUtils.getValueByXPath(performer, FINDING_PARTICIPANT_TIME_XPATH), DateTimeType.class);
    participantMapper.map(performer).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).map(Reference::new).forEach(it -> {
        EncounterParticipantComponent participant = new EncounterParticipantComponent();
        String modeCode = xmlUtils.getValueByXPath(performer, FINDING_PERFORMER_MODE_CODE_XPATH);
        participant.addExtension(PERFORMER_EXTENSION_URL, new CodeableConcept(new Coding().setSystem(ENCOUNTER_PARTICIPATION_MODE_SYSTEM).setCode(modeCode).setDisplay(getParticipationModeDisplay(modeCode))));
        encounter.addParticipant(participant.setPeriod(new Period().setStartElement(time)).addType(getParticipationType("PRF", "performer")).setIndividual(it));
    });
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) FINAL(org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL) Encounter(org.hl7.fhir.r4.model.Encounter) ENTEREDINERROR(org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR) Node(org.w3c.dom.Node) CodedEntryMapper(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntryMapper) Meta(org.hl7.fhir.r4.model.Meta) Observation(org.hl7.fhir.r4.model.Observation) NodeList(org.w3c.dom.NodeList) Period(org.hl7.fhir.r4.model.Period) Resource(org.hl7.fhir.r4.model.Resource) FINISHED(org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Component(org.springframework.stereotype.Component) List(java.util.List) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) PerformerParticipationMode.getParticipationModeDisplay(uk.nhs.adaptors.scr.mappings.from.hl7.PerformerParticipationMode.getParticipationModeDisplay) FhirHelper.randomUUID(uk.nhs.adaptors.scr.utils.FhirHelper.randomUUID) Optional(java.util.Optional) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Coding(org.hl7.fhir.r4.model.Coding) Period(org.hl7.fhir.r4.model.Period) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 27 with Time

use of org.hl7.elm.r1.Time in project summary-care-record-api by NHSDigital.

the class FindingMapper method mapAuthor.

private void mapAuthor(List<Resource> resources, Encounter encounter, Node author) {
    DateTimeType time = parseDate(xmlUtils.getValueByXPath(author, FINDING_PARTICIPANT_TIME_XPATH), DateTimeType.class);
    participantMapper.map(author).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).map(Reference::new).forEach(it -> encounter.addParticipant(new EncounterParticipantComponent().setPeriod(new Period().setStartElement(time)).addType(getParticipationType("AUT", "author")).setIndividual(it)));
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) FINAL(org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL) Encounter(org.hl7.fhir.r4.model.Encounter) ENTEREDINERROR(org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR) Node(org.w3c.dom.Node) CodedEntryMapper(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntryMapper) Meta(org.hl7.fhir.r4.model.Meta) Observation(org.hl7.fhir.r4.model.Observation) NodeList(org.w3c.dom.NodeList) Period(org.hl7.fhir.r4.model.Period) Resource(org.hl7.fhir.r4.model.Resource) FINISHED(org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Component(org.springframework.stereotype.Component) List(java.util.List) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) PerformerParticipationMode.getParticipationModeDisplay(uk.nhs.adaptors.scr.mappings.from.hl7.PerformerParticipationMode.getParticipationModeDisplay) FhirHelper.randomUUID(uk.nhs.adaptors.scr.utils.FhirHelper.randomUUID) Optional(java.util.Optional) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Period(org.hl7.fhir.r4.model.Period) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 28 with Time

use of org.hl7.elm.r1.Time in project drug-formulary-ri by HL7-DaVinci.

the class ExampleServerDstu3IT method testWebsocketSubscription.

@Test
public void testWebsocketSubscription() throws Exception {
    /*
		 * Create subscription
		 */
    Subscription subscription = new Subscription();
    subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)");
    subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED);
    subscription.setCriteria("Observation?status=final");
    Subscription.SubscriptionChannelComponent channel = new Subscription.SubscriptionChannelComponent();
    channel.setType(Subscription.SubscriptionChannelType.WEBSOCKET);
    channel.setPayload("application/json");
    subscription.setChannel(channel);
    MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
    IIdType mySubscriptionId = methodOutcome.getId();
    // Wait for the subscription to be activated
    waitForSize(1, () -> ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size());
    /*
		 * Attach websocket
		 */
    WebSocketClient myWebSocketClient = new WebSocketClient();
    SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);
    myWebSocketClient.start();
    URI echoUri = new URI("ws://localhost:" + ourPort + "/hapi-fhir-jpaserver/websocket");
    ClientUpgradeRequest request = new ClientUpgradeRequest();
    ourLog.info("Connecting to : {}", echoUri);
    Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
    Session session = connection.get(2, TimeUnit.SECONDS);
    ourLog.info("Connected to WS: {}", session.isOpen());
    /*
		 * Create a matching resource
		 */
    Observation obs = new Observation();
    obs.setStatus(Observation.ObservationStatus.FINAL);
    ourClient.create().resource(obs).execute();
    // Give some time for the subscription to deliver
    Thread.sleep(2000);
    /*
		 * Ensure that we receive a ping on the websocket
		 */
    waitForSize(1, () -> mySocketImplementation.myPingCount);
    /*
		 * Clean up
		 */
    ourClient.delete().resourceById(mySubscriptionId).execute();
}
Also used : CacheControlDirective(ca.uhn.fhir.rest.api.CacheControlDirective) WebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) URI(java.net.URI) Observation(org.hl7.fhir.dstu3.model.Observation) ClientUpgradeRequest(org.eclipse.jetty.websocket.client.ClientUpgradeRequest) Subscription(org.hl7.fhir.dstu3.model.Subscription) IIdType(org.hl7.fhir.instance.model.api.IIdType) Session(org.eclipse.jetty.websocket.api.Session) Test(org.junit.Test)

Example 29 with Time

use of org.hl7.elm.r1.Time in project ab2d by CMSgov.

the class PatientClaimsProcessorUnitTest method process_whenPatientHasDataWithBadLastUpdated.

@Test
void process_whenPatientHasDataWithBadLastUpdated() throws ExecutionException, InterruptedException {
    ExplanationOfBenefit firstEob = eob.copy();
    eob.getMeta().setLastUpdated(null);
    org.hl7.fhir.dstu3.model.Bundle bundle1 = EobTestDataUtil.createBundle(eob.copy());
    ExplanationOfBenefit eob2 = eob.copy();
    // now set the last updated date to a time before the since date (which is attribution date here)
    eob2.getMeta().setLastUpdated(new Date(LATER_ATT_DATE.toInstant().toEpochMilli() - 1000));
    final org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent bundleEntryComponent = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent();
    bundleEntryComponent.setResource(eob2);
    bundle1.addEntry(bundleEntryComponent);
    ExplanationOfBenefit eob3 = eob.copy();
    eob2.getMeta().setLastUpdated(new Date());
    final org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent bundleEntryComponent3 = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent();
    bundleEntryComponent3.setResource(eob3);
    bundle1.addEntry(bundleEntryComponent3);
    assertEquals(3, bundle1.getEntry().size());
    PatientClaimsRequest request2 = new PatientClaimsRequest(List.of(coverageSummary), LATER_ATT_DATE, LATER_ATT_DATE, "client", "job", "contractNum", Contract.ContractType.NORMAL, noOpToken, STU3, tmpEfsMountDir.getAbsolutePath());
    when(mockBfdClient.requestEOBFromServer(STU3, patientId, request2.getAttTime())).thenReturn(bundle1);
    cut.process(request2).get();
}
Also used : ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 30 with Time

use of org.hl7.elm.r1.Time in project integration-adaptor-111 by nhsconnect.

the class ParticipantMapperTest method shouldMapParticipant.

@Test
public void shouldMapParticipant() {
    POCDMT000002UK01Participant1 encounterParticipant = mock(POCDMT000002UK01Participant1.class);
    POCDMT000002UK01AssociatedEntity associatedEntity = mock(POCDMT000002UK01AssociatedEntity.class);
    IVLTS time = mock(IVLTS.class);
    when(encounterParticipant.getTypeCode()).thenReturn("CON");
    when(encounterParticipant.getAssociatedEntity()).thenReturn(associatedEntity);
    when(encounterParticipant.isSetTime()).thenReturn(true);
    when(encounterParticipant.getTime()).thenReturn(time);
    when(periodMapper.mapPeriod(ArgumentMatchers.isA(IVLTS.class))).thenReturn(period);
    when(practitionerMapper.mapPractitioner(ArgumentMatchers.isA(POCDMT000002UK01AssociatedEntity.class))).thenReturn(practitioner);
    when(resourceUtil.createReference(practitioner)).thenReturn(new Reference(practitioner));
    Encounter.EncounterParticipantComponent participantComponent = participantMapper.mapEncounterParticipant(encounterParticipant);
    assertThat(participantComponent.getIndividualTarget()).isEqualTo(practitioner);
    assertThat(participantComponent.getPeriod()).isEqualTo(period);
    assertThat(participantComponent.getType().get(0).getText()).isEqualTo("CON");
}
Also used : IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) Reference(org.hl7.fhir.dstu3.model.Reference) POCDMT000002UK01Participant1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Participant1) Encounter(org.hl7.fhir.dstu3.model.Encounter) POCDMT000002UK01AssociatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssociatedEntity) Test(org.junit.jupiter.api.Test)

Aggregations

Time (com.android.calendarcommon2.Time)178 ArrayList (java.util.ArrayList)64 List (java.util.List)40 Timer (com.codahale.metrics.Timer)27 Trace (com.newrelic.api.agent.Trace)23 Date (java.util.Date)23 Test (org.junit.jupiter.api.Test)23 IOException (java.io.IOException)21 FHIRException (org.hl7.fhir.exceptions.FHIRException)21 Paint (android.graphics.Paint)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)19 Resource (org.hl7.fhir.r4.model.Resource)19 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)18 Condition (org.hl7.fhir.r4.model.Condition)16 Optional (java.util.Optional)15 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)15 Bundle (org.hl7.fhir.r4.model.Bundle)15 Coding (org.hl7.fhir.r4.model.Coding)15 Reference (org.hl7.fhir.r4.model.Reference)15 HashMap (java.util.HashMap)14