PDMessageGeneratorUtils extends MessageGeneratorUtils { public II extractPatientIdFromSubject(PRPAIN201306UV02MFMIMT700711UV01Subject1 subject) { II id = null; boolean hasPatient = subject != null && subject.getRegistrationEvent() != null && subject.getRegistrationEvent().getSubject1() != null && subject.getRegistrationEvent().getSubject1(). getPatient() != null; boolean hasId = hasPatient && CollectionUtils.isNotEmpty(subject.getRegistrationEvent().getSubject1(). getPatient().getId()) && subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0) != null; if (hasId && NullChecker.isNotNullish(subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0) .getExtension()) && NullChecker.isNotNullish(subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0) .getRoot())) { id = new II(); id.setExtension(subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0).getExtension()); id.setRoot(subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0).getRoot()); } return id; } PDMessageGeneratorUtils(); static PDMessageGeneratorUtils getInstance(); II extractPatientIdFromSubject(PRPAIN201306UV02MFMIMT700711UV01Subject1 subject); CommunityPRPAIN201306UV02ResponseType createCommunityPRPAIN201306UV02ResponseType(String hcid); RespondingGatewayPRPAIN201305UV02RequestType createRespondingGatewayRequest(PRPAIN201305UV02 message,
        AssertionType assertion, NhinTargetCommunitiesType targets); RespondingGatewayPRPAIN201306UV02RequestType createRespondingGatewayRequest(PRPAIN201306UV02 message,
        AssertionType assertion, NhinTargetCommunitiesType target); NhinTargetSystemType createNhinTargetSystemType(String exchangeName, String url, String hcid);  }
@Test public void extractPatientIdFromSubject() { assertNull(msgUtils.extractPatientIdFromSubject(null)); PRPAIN201306UV02MFMIMT700711UV01Subject1 subject = new PRPAIN201306UV02MFMIMT700711UV01Subject1(); assertNull(msgUtils.extractPatientIdFromSubject(subject)); subject.setRegistrationEvent(new PRPAIN201306UV02MFMIMT700711UV01RegistrationEvent()); assertNull(msgUtils.extractPatientIdFromSubject(subject)); subject.getRegistrationEvent().setSubject1(new PRPAIN201306UV02MFMIMT700711UV01Subject2()); assertNull(msgUtils.extractPatientIdFromSubject(subject)); subject.getRegistrationEvent().getSubject1().setPatient(new PRPAMT201310UV02Patient()); assertNull(msgUtils.extractPatientIdFromSubject(subject)); subject.getRegistrationEvent().getSubject1().getPatient().getId().add(new II()); assertNull(msgUtils.extractPatientIdFromSubject(subject)); subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0).setExtension("extension"); assertNull(msgUtils.extractPatientIdFromSubject(subject)); subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0).setRoot("root"); II id = msgUtils.extractPatientIdFromSubject(subject); assertEquals("extension", id.getExtension()); assertEquals("root", id.getRoot()); }