001package ca.cdr.api.pub.hl7v2.common.abstraction;
002
003/*-
004 * #%L
005 * Smile CDR - CDR
006 * %%
007 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
008 * %%
009 * All rights reserved.
010 * #L%
011 */
012
013import ca.uhn.hl7v2.HL7Exception;
014import ca.uhn.hl7v2.model.AbstractMessage;
015
016/**
017 * Wraps a HL7 V2 message to an abstraction with relevant segments and groups
018 */
019public class WrapperFactory {
020        private WrapperFactory() {}
021
022        private static final EventMessageFactory ourEventMessageFactory = new EventMessageFactory();
023        private static final OrderMessageFactory ourOrderMessageFactory = new OrderMessageFactory();
024        private static final PatientMessageFactory ourPatientMessageFactory = new PatientMessageFactory();
025        private static final VisitMessageFactory ourVisitMessageFactory = new VisitMessageFactory();
026        private static final DocumentManagementMessageFactory ourDocumentManagementMessageFactory =
027                        new DocumentManagementMessageFactory();
028
029        public static IEventMessage asEventMessage(AbstractMessage theMessage) {
030                return ourEventMessageFactory.asEventMessage(theMessage);
031        }
032
033        public static IOrderMessage asOrderMessage(AbstractMessage theMessage) throws HL7Exception {
034                return ourOrderMessageFactory.asOrderMessage(theMessage);
035        }
036
037        public static IPatientMessage asPatientMessage(AbstractMessage theMessage) throws HL7Exception {
038                return ourPatientMessageFactory.asPatientMessage(theMessage);
039        }
040
041        public static IVisitMessage asVisitMessage(AbstractMessage theMessage) throws HL7Exception {
042                return ourVisitMessageFactory.asVisitMessage(theMessage);
043        }
044
045        public static IDocumentManagementMessage asDocumentManagementMessage(AbstractMessage theModifiableMessage)
046                        throws HL7Exception {
047                return ourDocumentManagementMessageFactory.asDocumentManagementMessage(theModifiableMessage);
048        }
049}