Java Code Examples for ca.uhn.hl7v2.model.DataTypeException

The following are top voted examples for showing how to use ca.uhn.hl7v2.model.DataTypeException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
private static GregorianCalendar getCalendarFromDT(DT dt) throws DataTypeException {

		// hl7/hapi returns 0 for no date
		if (dt.getYear() == 0 || dt.getMonth() == 0 || dt.getDay() == 0) return (null);

		GregorianCalendar cal = new GregorianCalendar();
		// zero out fields we don't use
		cal.setTimeInMillis(0);
		cal.set(GregorianCalendar.YEAR, dt.getYear());
		cal.set(GregorianCalendar.MONTH, dt.getMonth() - 1);
		cal.set(GregorianCalendar.DAY_OF_MONTH, dt.getDay());

		// force materialisation of values
		cal.getTimeInMillis();

		return (cal);
	}
 
Example 2
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
public static GregorianCalendar getCalendarFromDTM(DTM dtm) throws DataTypeException {

		// hl7/hapi returns 0 for no date
		if (dtm.getYear() == 0 || dtm.getMonth() == 0 || dtm.getDay() == 0) return (null);

		GregorianCalendar cal = new GregorianCalendar();
		// zero out fields we don't use
		cal.setTimeInMillis(0);
		cal.set(GregorianCalendar.YEAR, dtm.getYear());
		cal.set(GregorianCalendar.MONTH, dtm.getMonth() - 1);
		cal.set(GregorianCalendar.DAY_OF_MONTH, dtm.getDay());
		cal.set(GregorianCalendar.HOUR_OF_DAY, dtm.getHour());
		cal.set(GregorianCalendar.MINUTE, dtm.getMinute());
		cal.set(GregorianCalendar.SECOND, dtm.getSecond());

		// force materialisation of values
		cal.getTimeInMillis();

		return (cal);
	}
 
Example 3
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
/**
 * @param msh
 * @param dateOfMessage
 * @param clinicName 
 * @param messageCode i.e. "REF"
 * @param triggerEvent i.e. "I12"
 * @param messageStructure i.e. "REF_I12"
 * @param hl7VersionId is the version of hl7 in use, i.e. "2.6"
 */
public static void fillMsh(MSH msh, Date dateOfMessage, String clinicName, String messageCode, String triggerEvent, String messageStructure, String hl7VersionId) throws DataTypeException {
	msh.getFieldSeparator().setValue("|");
	msh.getEncodingCharacters().setValue("^~\\&");
	msh.getVersionID().getVersionID().setValue(hl7VersionId);

	msh.getDateTimeOfMessage().setValue(getAsHl7FormattedString(dateOfMessage));

	msh.getSendingApplication().getNamespaceID().setValue("OSCAR");

	msh.getSendingFacility().getNamespaceID().setValue(clinicName);

	// message code "REF", event "I12", structure "REF I12"
	msh.getMessageType().getMessageCode().setValue(messageCode);
	msh.getMessageType().getTriggerEvent().setValue(triggerEvent);
	msh.getMessageType().getMessageStructure().setValue(messageStructure);
}
 
Example 4
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
/**
 * @param prd
 * @param provider
 * @param providerRoleId Note that this is not the oscar provider role, look in the method to see valid values
 * @param providerRoleDescription Note that this is not the oscar provider role, look in the method to see valid values
 */
public static void fillPrd(PRD prd, Provider provider, String providerRoleId, String providerRoleDescription, Clinic clinic) throws DataTypeException, HL7Exception {
	// Value Description
	// -----------------
	// RP Referring Provider
	// PP Primary Care Provider
	// CP Consulting Provider
	// RT Referred to Provider
	prd.getProviderRole(0).getIdentifier().setValue(providerRoleId);
	prd.getProviderRole(0).getText().setValue(providerRoleDescription);

	XPN xpn = prd.getProviderName(0);
	xpn.getFamilyName().getSurname().setValue(provider.getLastName());
	xpn.getGivenName().setValue(provider.getFirstName());
	xpn.getPrefixEgDR().setValue(provider.getTitle());

	XAD xad = prd.getProviderAddress(0);
	fillXAD(xad, clinic, null, "O");

	XTN xtn = prd.getProviderCommunicationInformation(0);
	xtn.getUnformattedTelephoneNumber().setValue(provider.getWorkPhone());
	xtn.getCommunicationAddress().setValue(provider.getEmail());

	PLN pln = prd.getProviderIdentifiers(0);
	pln.getIDNumber().setValue(provider.getProviderNo());
}
 
Example 5
Project: Camel   File: HL7ValidateTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testUnmarshalFailed() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:unmarshal");
    mock.expectedMessageCount(0);

    String body = createHL7AsString();
    try {
        template.sendBody("direct:unmarshalFailed", body);
        fail("Should have thrown exception");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(HL7Exception.class, e.getCause());
        assertIsInstanceOf(DataTypeException.class, e.getCause());
        assertTrue("Should be a validation error message", e.getCause().getMessage().startsWith("ca.uhn.hl7v2.validation.ValidationException: Validation failed:"));
    }

    assertMockEndpointsSatisfied();
}
 
Example 6
Project: AvoinApotti   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderMemberOfStaffShortVoToXCNNatCode(MemberOfStaffShortVo mos, XCN xcn,ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderMemberOfStaffShortVoToXCNNatCode: entry");

	if(mos!=null&&mos.getNameIsNotNull()&&mos.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(mos.getName().getForename());
	if(mos!=null&&mos.getNameIsNotNull()&&mos.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(mos.getName().getSurname());
	if(mos!=null&&mos.getNationalConsCode()!=null)
	{
		xcn.getIDNumber().setValue(mos.getNationalConsCode());
	}
	else if(mos!=null)
	{
		TaxonomyMap mapping = mos.getExternalCode(providerSystem.getCodeSystem());
		if (mapping != null)
		{
			xcn.getIDNumber().setValue(mapping.getTaxonomyCode());			
		}
	}
	LOG.debug("VoMapper renderMemberOfStaffShortVoToXCNNatCode: exit");

}
 
Example 7
Project: AvoinApotti   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderGpShortVoToXCN(GpShortVo gp,XCN xcn,ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderGpShortVoToXCN: entry");
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(gp.getName().getForename());
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(gp.getName().getSurname());
	TaxonomyMap mapping = null;
	if (gp!=null)
		mapping = gp.getExternalCode(TaxonomyType.NAT_GP_CODE);
	if(mapping!=null)
	{
		xcn.getIDNumber().setValue(mapping.getTaxonomyCode());
	}
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getTitleIsNotNull())
		xcn.getPrefixEgDR().setValue(svc.getRemoteLookup(gp.getName().getTitle().getID(), providerSystem.getCodeSystem().getText()));
	LOG.debug("VoMapper renderGpShortVoToXCN: exit");
}
 
Example 8
Project: AvoinApotti   File: A03VoMapper.java   Source Code and License 6 votes vote down vote up
public CareContextRefVo getCareContextFromPV1(PV1 pv) throws DataTypeException
{
	String visitId=pv.getVisitNumber().getID().getValue() + "_" + pv.getVisitNumber().getComponent(1);
	String pasEpisodeId = pv.getAlternateVisitID().getID().getValue();
	CareContextInterfaceVo careContext;
	
	if (pasEpisodeId!=null)
	{
		careContext=careSpellDialog.getCareContextFromPasEpisodeId(pasEpisodeId,visitId);
		if (careContext!=null)
		{
			if (careContext.getEpisodeOfCare()!=null)
			{
				setCareContextContext(careContext.getID_CareContext(),careContext.getEpisodeOfCare().getID_EpisodeOfCare());
				return (CareContextRefVo)careContext;
			}
		}
	}	
	return null;
}
 
Example 9
Project: openMAXIMS   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderGpShortVoToXCN(GpShortVo gp, XCN xcn, ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderGpShortVoToXCN: entry");
	
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(gp.getName().getForename());
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(gp.getName().getSurname());
	TaxonomyMap mapping = null;
	if (gp!=null)
		mapping = gp.getExternalCode(TaxonomyType.NAT_GP_CODE);
	if(mapping!=null)
	{
		xcn.getIDNumber().setValue(mapping.getTaxonomyCode());
	}
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getTitleIsNotNull())
		xcn.getPrefixEgDR().setValue(svc.getRemoteLookup(gp.getName().getTitle().getID(), providerSystem.getCodeSystem().getText()));

	LOG.debug("VoMapper renderGpShortVoToXCN: exit");
}
 
Example 10
Project: openMAXIMS   File: A03VoMapper.java   Source Code and License 6 votes vote down vote up
public CareContextRefVo getCareContextFromPV1(PV1 pv) throws DataTypeException
{
	String visitId=pv.getVisitNumber().getID().getValue() + "_" + pv.getVisitNumber().getComponent(1);
	String pasEpisodeId = pv.getAlternateVisitID().getID().getValue();
	CareContextInterfaceVo careContext;
	
	if (pasEpisodeId!=null)
	{
		careContext=careSpellDialog.getCareContextFromPasEpisodeId(pasEpisodeId,visitId);
		if (careContext!=null)
		{
			if (careContext.getEpisodeOfCare()!=null)
			{
				setCareContextContext(careContext.getID_CareContext(),careContext.getEpisodeOfCare().getID_EpisodeOfCare());
				return (CareContextRefVo)careContext;
			}
		}
	}	
	return null;
}
 
Example 11
Project: openMAXIMS   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderMemberOfStaffShortVoToXCNNatCode(MemberOfStaffShortVo mos, XCN xcn,ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderMemberOfStaffShortVoToXCNNatCode: entry");

	if(mos!=null&&mos.getNameIsNotNull()&&mos.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(mos.getName().getForename());
	if(mos!=null&&mos.getNameIsNotNull()&&mos.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(mos.getName().getSurname());
	if(mos!=null&&mos.getNationalConsCode()!=null)
	{
		xcn.getIDNumber().setValue(mos.getNationalConsCode());
	}
	else if(mos!=null)
	{
		TaxonomyMap mapping = mos.getExternalCode(providerSystem.getCodeSystem());
		if (mapping != null)
		{
			xcn.getIDNumber().setValue(mapping.getTaxonomyCode());			
		}
	}
	LOG.debug("VoMapper renderMemberOfStaffShortVoToXCNNatCode: exit");

}
 
Example 12
Project: openMAXIMS   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderGpShortVoToXCN(GpShortVo gp,XCN xcn,ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderGpShortVoToXCN: entry");
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(gp.getName().getForename());
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(gp.getName().getSurname());
	TaxonomyMap mapping = null;
	if (gp!=null)
		mapping = gp.getExternalCode(TaxonomyType.NAT_GP_CODE);
	if(mapping!=null)
	{
		xcn.getIDNumber().setValue(mapping.getTaxonomyCode());
	}
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getTitleIsNotNull())
		xcn.getPrefixEgDR().setValue(svc.getRemoteLookup(gp.getName().getTitle().getID(), providerSystem.getCodeSystem().getText()));
	LOG.debug("VoMapper renderGpShortVoToXCN: exit");
}
 
Example 13
Project: openMAXIMS   File: A03VoMapper.java   Source Code and License 6 votes vote down vote up
public CareContextRefVo getCareContextFromPV1(PV1 pv) throws DataTypeException
{
	String visitId=pv.getVisitNumber().getID().getValue() + "_" + pv.getVisitNumber().getComponent(1);
	String pasEpisodeId = pv.getAlternateVisitID().getID().getValue();
	CareContextInterfaceVo careContext;
	
	if (pasEpisodeId!=null)
	{
		careContext=careSpellDialog.getCareContextFromPasEpisodeId(pasEpisodeId,visitId);
		if (careContext!=null)
		{
			if (careContext.getEpisodeOfCare()!=null)
			{
				setCareContextContext(careContext.getID_CareContext(),careContext.getEpisodeOfCare().getID_EpisodeOfCare());
				return (CareContextRefVo)careContext;
			}
		}
	}	
	return null;
}
 
Example 14
Project: openmaxims-linux   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderMemberOfStaffShortVoToXCNNatCode(MemberOfStaffShortVo mos, XCN xcn,ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderMemberOfStaffShortVoToXCNNatCode: entry");

	if(mos!=null&&mos.getNameIsNotNull()&&mos.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(mos.getName().getForename());
	if(mos!=null&&mos.getNameIsNotNull()&&mos.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(mos.getName().getSurname());
	if(mos!=null&&mos.getNationalConsCode()!=null)
	{
		xcn.getIDNumber().setValue(mos.getNationalConsCode());
	}
	else if(mos!=null)
	{
		TaxonomyMap mapping = mos.getExternalCode(providerSystem.getCodeSystem());
		if (mapping != null)
		{
			xcn.getIDNumber().setValue(mapping.getTaxonomyCode());			
		}
	}
	LOG.debug("VoMapper renderMemberOfStaffShortVoToXCNNatCode: exit");

}
 
Example 15
Project: openmaxims-linux   File: VoMapper.java   Source Code and License 6 votes vote down vote up
protected final void renderGpShortVoToXCN(GpShortVo gp,XCN xcn,ProviderSystemVo providerSystem) throws DataTypeException
{
	LOG.debug("VoMapper renderGpShortVoToXCN: entry");
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getForenameIsNotNull())
		xcn.getGivenName().setValue(gp.getName().getForename());
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getSurnameIsNotNull())
		xcn.getFamilyName().getSurname().setValue(gp.getName().getSurname());
	TaxonomyMap mapping = null;
	if (gp!=null)
		mapping = gp.getExternalCode(TaxonomyType.NAT_GP_CODE);
	if(mapping!=null)
	{
		xcn.getIDNumber().setValue(mapping.getTaxonomyCode());
	}
	if(gp!=null&&gp.getNameIsNotNull()&&gp.getName().getTitleIsNotNull())
		xcn.getPrefixEgDR().setValue(svc.getRemoteLookup(gp.getName().getTitle().getID(), providerSystem.getCodeSystem().getText()));
	LOG.debug("VoMapper renderGpShortVoToXCN: exit");
}
 
Example 16
Project: openmaxims-linux   File: A03VoMapper.java   Source Code and License 6 votes vote down vote up
public CareContextRefVo getCareContextFromPV1(PV1 pv) throws DataTypeException
{
	String visitId=pv.getVisitNumber().getID().getValue() + "_" + pv.getVisitNumber().getComponent(1);
	String pasEpisodeId = pv.getAlternateVisitID().getID().getValue();
	CareContextInterfaceVo careContext;
	
	if (pasEpisodeId!=null)
	{
		careContext=careSpellDialog.getCareContextFromPasEpisodeId(pasEpisodeId,visitId);
		if (careContext!=null)
		{
			if (careContext.getEpisodeOfCare()!=null)
			{
				setCareContextContext(careContext.getID_CareContext(),careContext.getEpisodeOfCare().getID_EpisodeOfCare());
				return (CareContextRefVo)careContext;
			}
		}
	}	
	return null;
}
 
Example 17
Project: oscar-old   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
private static GregorianCalendar getCalendarFromDT(DT dt) throws DataTypeException {

		// hl7/hapi returns 0 for no date
		if (dt.getYear() == 0 || dt.getMonth() == 0 || dt.getDay() == 0) return (null);

		GregorianCalendar cal = new GregorianCalendar();
		// zero out fields we don't use
		cal.setTimeInMillis(0);
		cal.set(GregorianCalendar.YEAR, dt.getYear());
		cal.set(GregorianCalendar.MONTH, dt.getMonth() - 1);
		cal.set(GregorianCalendar.DAY_OF_MONTH, dt.getDay());

		// force materialisation of values
		cal.getTimeInMillis();

		return (cal);
	}
 
Example 18
Project: oscar-old   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
public static GregorianCalendar getCalendarFromDTM(DTM dtm) throws DataTypeException {

		// hl7/hapi returns 0 for no date
		if (dtm.getYear() == 0 || dtm.getMonth() == 0 || dtm.getDay() == 0) return (null);

		GregorianCalendar cal = new GregorianCalendar();
		// zero out fields we don't use
		cal.setTimeInMillis(0);
		cal.set(GregorianCalendar.YEAR, dtm.getYear());
		cal.set(GregorianCalendar.MONTH, dtm.getMonth() - 1);
		cal.set(GregorianCalendar.DAY_OF_MONTH, dtm.getDay());
		cal.set(GregorianCalendar.HOUR_OF_DAY, dtm.getHour());
		cal.set(GregorianCalendar.MINUTE, dtm.getMinute());
		cal.set(GregorianCalendar.SECOND, dtm.getSecond());

		// force materialisation of values
		cal.getTimeInMillis();

		return (cal);
	}
 
Example 19
Project: oscar-old   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
/**
 * @param msh
 * @param dateOfMessage
 * @param facilityName facility.getName();
 * @param messageCode i.e. "REF"
 * @param triggerEvent i.e. "I12"
 * @param messageStructure i.e. "REF_I12"
 * @param hl7VersionId is the version of hl7 in use, i.e. "2.6"
 */
public static void fillMsh(MSH msh, Date dateOfMessage, String clinicName, String messageCode, String triggerEvent, String messageStructure, String hl7VersionId) throws DataTypeException {
	msh.getFieldSeparator().setValue("|");
	msh.getEncodingCharacters().setValue("^~\\&");
	msh.getVersionID().getVersionID().setValue(hl7VersionId);

	msh.getDateTimeOfMessage().setValue(getAsHl7FormattedString(dateOfMessage));

	msh.getSendingApplication().getNamespaceID().setValue("OSCAR");

	msh.getSendingFacility().getNamespaceID().setValue(clinicName);

	// message code "REF", event "I12", structure "REF I12"
	msh.getMessageType().getMessageCode().setValue(messageCode);
	msh.getMessageType().getTriggerEvent().setValue(triggerEvent);
	msh.getMessageType().getMessageStructure().setValue(messageStructure);
}
 
Example 20
Project: oscar-old   File: DataTypeUtils.java   Source Code and License 6 votes vote down vote up
/**
 * @param prd
 * @param provider
 * @param providerRoleId Note that this is not the oscar provider role, look in the method to see valid values
 * @param providerRoleDescription Note that this is not the oscar provider role, look in the method to see valid values
 */
public static void fillPrd(PRD prd, Provider provider, String providerRoleId, String providerRoleDescription, Clinic clinic) throws DataTypeException, HL7Exception {
	// Value Description
	// -----------------
	// RP Referring Provider
	// PP Primary Care Provider
	// CP Consulting Provider
	// RT Referred to Provider
	prd.getProviderRole(0).getIdentifier().setValue(providerRoleId);
	prd.getProviderRole(0).getText().setValue(providerRoleDescription);

	XPN xpn = prd.getProviderName(0);
	xpn.getFamilyName().getSurname().setValue(provider.getLastName());
	xpn.getGivenName().setValue(provider.getFirstName());
	xpn.getPrefixEgDR().setValue(provider.getTitle());

	XAD xad = prd.getProviderAddress(0);
	fillXAD(xad, clinic, null, "O");

	XTN xtn = prd.getProviderCommunicationInformation(0);
	xtn.getUnformattedTelephoneNumber().setValue(provider.getWorkPhone());
	xtn.getCommunicationAddress().setValue(provider.getEmail());

	PLN pln = prd.getProviderIdentifiers(0);
	pln.getIDNumber().setValue(provider.getProviderNo());
}
 
Example 21
Project: rassyeyanie   File: HL7ValidateTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testUnmarshalFailed() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:unmarshal");
    mock.expectedMessageCount(0);

    String body = createHL7AsString();
    try {
        template.sendBody("direct:unmarshalFailed", body);
        fail("Should have thrown exception");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(HL7Exception.class, e.getCause());
        assertIsInstanceOf(DataTypeException.class, e.getCause());
        assertTrue("Should be a validation error message", e.getCause().getMessage().startsWith("Failed validation rule"));
    }

    assertMockEndpointsSatisfied();
}
 
Example 22
Project: elexis-3-core   File: HL7Writer.java   Source Code and License 6 votes vote down vote up
/**
 * Fills PID segment
 * 
 * @param pid
 * @param patient
 * @throws DataTypeException
 * @throws HL7Exception
 */
protected void fillPID(final PID pid, final HL7Patient patient) throws DataTypeException,
	HL7Exception{
	String sex = ""; //$NON-NLS-1$
	if (patient.isMale() != null) {
		sex = "M"; //$NON-NLS-1$
		if (!patient.isMale().booleanValue()) {
			sex = "F"; //$NON-NLS-1$
		}
	}
	pid.getPid1_SetIDPID().setValue("1"); //$NON-NLS-1$
	pid.getPid2_PatientID().getIDNumber().setValue(patient.getPatCode());
	pid.getPid3_PatientIdentifierList(0).getIDNumber().setValue(patient.getPatCode());
	pid.getPid4_AlternatePatientIDPID(0).getIDNumber().setValue(patient.getPatCode());
	addKontaktToXPN(pid.getPid5_PatientName(0), patient);
	pid.getPid16_MaritalStatus().getCwe1_Identifier().setValue(""); //$NON-NLS-1$
	pid.getPid7_DateTimeOfBirth().setValue(HL7Helper.dateToString(patient.getBirthdate()));
	
	pid.getPid8_AdministrativeSex().setValue(sex);
	pid.getPid9_PatientAlias(0).getXpn1_FamilyName().getFn1_Surname().setValue(""); //$NON-NLS-1$
	pid.getPid10_Race(0).getCwe1_Identifier().setValue(""); //$NON-NLS-1$
	addAddressToXAD(pid.getPid11_PatientAddress(0), patient);
	pid.getPid12_CountyCode().setValue(""); //$NON-NLS-1$
	addPhone1ToXTN(pid.getPid13_PhoneNumberHome(0), patient);
	addPhone2ToXTN(pid.getPid14_PhoneNumberBusiness(0), patient);
}
 
Example 23
Project: elexis-3-core   File: HL7Writer.java   Source Code and License 6 votes vote down vote up
/**
 * Adds patient data to XPN segment
 * 
 * @param xpn
 * @param patient
 * @throws DataTypeException
 */
protected void addKontaktToXPN(XPN xpn, final HL7Kontakt kontakt) throws DataTypeException{
	String name = ""; //$NON-NLS-1$
	String vorname = ""; //$NON-NLS-1$
	String title = ""; //$NON-NLS-1$
	if (kontakt != null) {
		name = kontakt.getName();
		vorname = kontakt.getFirstname();
		title = kontakt.getTitle();
	}
	xpn.getXpn1_FamilyName().getSurname().setValue(name);
	xpn.getXpn2_GivenName().setValue(vorname);
	xpn.getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().setValue(""); //$NON-NLS-1$
	xpn.getXpn4_SuffixEgJRorIII().setValue(""); //$NON-NLS-1$
	xpn.getXpn5_PrefixEgDR().setValue(""); //$NON-NLS-1$
	xpn.getXpn6_DegreeEgMD().setValue(title);
	xpn.getXpn7_NameTypeCode().setValue(""); //$NON-NLS-1$
	xpn.getXpn8_NameRepresentationCode().setValue(""); //$NON-NLS-1$
	xpn.getXpn9_NameContext().getCwe1_Identifier().setValue(""); //$NON-NLS-1$
}
 
Example 24
Project: elexis-3-core   File: HL7Writer.java   Source Code and License 6 votes vote down vote up
/**
 * Adds address of kontakt to XAD segment
 * 
 * @param xad
 * @param kontakt
 * @throws DataTypeException
 */
protected void addAddressToXAD(XAD xad, final HL7Kontakt kontakt) throws DataTypeException{
	String street = ""; //$NON-NLS-1$
	String other = ""; //$NON-NLS-1$
	String city = ""; //$NON-NLS-1$
	String zip = ""; //$NON-NLS-1$
	String country = ""; //$NON-NLS-1$
	if (kontakt != null) {
		street = kontakt.getAddress1();
		other = kontakt.getAddress2();
		city = kontakt.getCity();
		zip = kontakt.getZip();
		country = kontakt.getCountry();
	}
	xad.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue(street);
	xad.getXad2_OtherDesignation().setValue(other);
	xad.getXad3_City().setValue(city);
	xad.getXad4_StateOrProvince().setValue(""); //$NON-NLS-1$
	xad.getXad5_ZipOrPostalCode().setValue(zip);
	xad.getXad6_Country().setValue(country);
}
 
Example 25
Project: elexis-3-core   File: HL7Writer.java   Source Code and License 6 votes vote down vote up
/**
 * Adds contact informations to XTN segment
 * 
 * @param xtn
 * @param kontakt
 * @throws DataTypeException
 */
protected void addPhone1ToXTN(XTN xtn, final HL7Kontakt kontakt) throws DataTypeException{
	String phone1 = ""; //$NON-NLS-1$
	String email = ""; //$NON-NLS-1$
	String fax = ""; //$NON-NLS-1$
	if (kontakt != null) {
		phone1 = kontakt.getPhone1();
		email = kontakt.getEmail();
		fax = kontakt.getFax();
	}
	xtn.getXtn1_TelephoneNumber().setValue(phone1);
	xtn.getXtn2_TelecommunicationUseCode().setValue(""); //$NON-NLS-1$
	xtn.getXtn3_TelecommunicationEquipmentType().setValue(""); //$NON-NLS-1$
	xtn.getXtn4_CommunicationAddress().setValue(email);
	xtn.getXtn5_CountryCode().setValue(""); //$NON-NLS-1$
	xtn.getXtn6_AreaCityCode().setValue(""); //$NON-NLS-1$
	xtn.getXtn7_LocalNumber().setValue(""); //$NON-NLS-1$
	xtn.getXtn8_Extension().setValue(""); //$NON-NLS-1$
	xtn.getXtn9_AnyText().setValue(""); //$NON-NLS-1$
	xtn.getXtn10_ExtensionPrefix().setValue(""); //$NON-NLS-1$
	xtn.getXtn11_SpeedDialCode().setValue(fax);
}
 
Example 26
Project: elexis-3-core   File: HL7_OML_O21.java   Source Code and License 6 votes vote down vote up
/**
 * Creates an OMG_O19 message
 * 
 * @param patient
 * @param kostentraeger
 * @param rechnungsempfaenger
 * @param auftragsNummer
 * @param plan
 *            Abrechnungssystem (MV, UVG, VVG, KVG, usw)
 * @param beginDate
 * @param vnr
 *            Versicherungs-, Fall- oder Unfallnr
 * @return
 */
public String createText(final HL7Patient patient, final HL7Kostentraeger rechnungsempfaenger,
	final HL7Kostentraeger kostentraeger, final String plan, final Date beginDate,
	final String fallNr, final long auftragsNummer) throws DataTypeException, HL7Exception{
	
	OML_O21 omg = new OML_O21();
	fillMSH(omg.getMSH(), "OML", "O21", mandant, this.uniqueMessageControlID, //$NON-NLS-1$ //$NON-NLS-2$
		this.uniqueProcessingID, patient); //$NON-NLS-1$ //$NON-NLS-2$
	fillPID(omg.getPATIENT().getPID(), patient);
	fillNK1(omg.getPATIENT().getNK1(), rechnungsempfaenger);
	fillPV1(omg.getPATIENT().getPATIENT_VISIT().getPV1(), patient, beginDate);
	fillIN1(omg.getPATIENT().getINSURANCE().getIN1(), patient, kostentraeger, plan, fallNr);
	fillORC(omg.getORDER().getORC(), "1", auftragsNummer); //$NON-NLS-1$
	
	// Now, let's encode the message and look at the output
	Parser parser = new PipeParser();
	return parser.encode(omg);
}
 
Example 27
Project: elexis-3-core   File: HL7_OML_O21.java   Source Code and License 6 votes vote down vote up
/**
 * Fills PV1 segment
 * 
 * @param pv1
 * @param patient
 * @throws DataTypeException
 * @throws HL7Exception
 */
private void fillPV1(final PV1 pv1, final HL7Patient patient, final Date beginDate)
	throws DataTypeException, HL7Exception{
	pv1.getPv11_SetIDPV1().setValue("1"); //$NON-NLS-1$
	pv1.getPv12_PatientClass().setValue("O"); //$NON-NLS-1$
	
	// PLV-13: Aktueller Aufenthaltsort des Patienten, optional
	// Empfehlung: Wenn vorhanden, dann ausfüllen -> In unserem Fall leer lassen
	pv1.getPv14_AdmissionType().setValue(""); //$NON-NLS-1$
	pv1.getPv15_PreadmitNumber().getCx1_IDNumber().setValue(""); //$NON-NLS-1$
	pv1.getPv16_PriorPatientLocation().getPl1_PointOfCare().setValue(""); //$NON-NLS-1$
	
	// Fallnummer, optional (Beschreibung gemäss HL7 Standard)
	// Empfehlung: Wenn vorhanden, dann ausfüllen -> In unserem Fall leer lassen oder den Key
	// des Falles nehmen
	pv1.getPv119_VisitNumber().getIDNumber().setValue(""); //$NON-NLS-1$
	// ...
	pv1.getPv144_AdmitDateTime().setValue(HL7Helper.dateToString(beginDate));
}
 
Example 28
Project: elexis-3-core   File: HL7_OML_O21.java   Source Code and License 6 votes vote down vote up
/**
 * Fills IN1 segment
 * 
 * @param in1
 * @param patient
 * @param kostentraeger
 * @throws DataTypeException
 * @throws HL7Exception
 */
private void fillIN1(final IN1 in1, final HL7Patient patient,
	final HL7Kostentraeger kostentraeger, final String plan, final String fallNr)
	throws DataTypeException, HL7Exception{
	in1.getIn11_SetIDIN1().setValue("1"); //$NON-NLS-1$
	in1.getIn12_InsurancePlanID().getCwe1_Identifier().setValue(plan);
	// EAN Nummer der Versicherung
	// Beispiel: EAN123456789^^^CHEMEDIAT;
	in1.getIn13_InsuranceCompanyID(0).getCx1_IDNumber()
		.setValue("EAN" + kostentraeger.getEan()); //$NON-NLS-1$
	in1.getIn13_InsuranceCompanyID(0).getCx4_AssigningAuthority().getHd1_NamespaceID()
		.setValue("CHEMEDIAT"); //$NON-NLS-1$
	in1.getIn14_InsuranceCompanyName(0).getXon1_OrganizationName()
		.setValue(kostentraeger.getName());
	
	addAddressToXAD(in1.getIn15_InsuranceCompanyAddress(0), kostentraeger);
	addKontaktToXPN(in1.getIn116_NameOfInsured(0), patient);
	in1.getIn136_PolicyNumber().setValue(fallNr);
	
	addAddressToXAD(in1.getIn119_InsuredSAddress(0), patient);
}
 
Example 29
Project: elexis-3-core   File: HL7_ORU_R01.java   Source Code and License 6 votes vote down vote up
/**
 * Creates an ORU_R01 message
 * 
 * @param patient
 * @param labItem
 * @param labwert
 * 
 * @return
 */
public String createText(final HL7Patient patient, final HL7LaborItem labItem,
	final HL7LaborWert labwert) throws DataTypeException, HL7Exception{
	
	ORU_R01 oru = new ORU_R01();
	// Message
	fillMSH(oru.getMSH(), "ORU", "R01", mandant, this.uniqueMessageControlID, //$NON-NLS-1$ //$NON-NLS-2$
		this.uniqueProcessingID, patient); //$NON-NLS-1$ //$NON-NLS-2$
	
	// Patient
	PID pid = oru.getPATIENT_RESULT().getPATIENT().getPID();
	fillPID(pid, patient);
	
	ORU_R01_ORDER_OBSERVATION orderObservation = oru.getPATIENT_RESULT().getORDER_OBSERVATION();
	fillORC(orderObservation.getORC(), "RE", null); //$NON-NLS-1$
	
	addResultInternal(oru, patient, labItem, labwert, 0);
	
	// Now, let's encode the message and look at the output
	Parser parser = new PipeParser();
	return parser.encode(oru);
}
 
Example 30
Project: elexis-3-core   File: HL7_ORU_R01.java   Source Code and License 6 votes vote down vote up
/**
 * Adds a ORU_R01 observation result
 * 
 * @param oru
 * @param patient
 * @param labItem
 * @param labwert
 * @param initial
 * @return
 */
private String addResultInternal(final ORU_R01 oru, final HL7Patient patient,
	final HL7LaborItem labItem, final HL7LaborWert labwert, int orderObservationIndex)
	throws DataTypeException, HL7Exception{
	
	// Observation
	ORU_R01_ORDER_OBSERVATION orderObservation =
		(ORU_R01_ORDER_OBSERVATION) oru.getPATIENT_RESULT().getORDER_OBSERVATION(
			orderObservationIndex);
	fillOBR(orderObservation.getOBR(), orderObservationIndex, labItem);
	fillOBX(orderObservation.getOBSERVATION().getOBX(), patient, labItem, labwert);
	if (labwert.getKommentar() != null && labwert.getKommentar().length() > 0) {
		fillNTE(orderObservation.getNTE(), labwert);
	}
	// Now, let's encode the message and look at the output
	Parser parser = new PipeParser();
	return parser.encode(oru);
}
 
Example 31
Project: elexis-3-core   File: HL7_ORU_R01.java   Source Code and License 6 votes vote down vote up
/**
 * Fills OBR segment
 * 
 * @param obr
 * @param labItem
 * @throws DataTypeException
 * @throws HL7Exception
 */
private void fillOBR(final OBR obr, final int index, final HL7LaborItem labItem)
	throws DataTypeException, HL7Exception{
	obr.getObr1_SetIDOBR().setValue(new Integer(index + 1).toString());
	
	// OBR-4: Observation Identifier <LabResult.ID>^<LabItems.KUERZEL>^^^^^^^<LabItems.TITEL>
	CWE cwe4 = obr.getObr4_UniversalServiceIdentifier();
	cwe4.getCwe1_Identifier().setValue(labItem.getId());
	cwe4.getCwe2_Text().setValue(labItem.getKuerzel());
	cwe4.getCwe9_OriginalText().setValue(labItem.getTitel());
	
	// OBR-47: <ID der Gruppe>^<Gruppe>^99DGC~<Position>^^99DGP
	CWE egc = obr.getFillerSupplementalServiceInformation(0);
	egc.getCwe2_Text().setValue(labItem.getGruppe());
	egc.getCwe3_NameOfCodingSystem().setValue("99EGC");
	CWE egp = obr.getFillerSupplementalServiceInformation(1);
	egp.getCwe1_Identifier().setValue(labItem.getPrio());
	egp.getCwe3_NameOfCodingSystem().setValue("99EGP");
}
 
Example 32
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 5 votes vote down vote up
/**
 * @param xad
 * @param clinic
 * @param country iso 3166, 3 digit version / hl70399 code, i.e. USA, CAN, AUS in upper case.
 * @param addressType hlt0190 code, i.e. O=office, H=Home
 * @throws DataTypeException
 */
public static void fillXAD(XAD xad, Clinic clinic, String country, String addressType) throws DataTypeException {
	xad.getStreetAddress().getStreetOrMailingAddress().setValue(StringUtils.trimToNull(clinic.getClinicAddress()));
	xad.getCity().setValue(StringUtils.trimToNull(clinic.getClinicCity()));
	xad.getStateOrProvince().setValue(StringUtils.trimToNull(clinic.getClinicProvince()));
	if (country != null) xad.getCountry().setValue(StringUtils.trimToNull(country));
	xad.getZipOrPostalCode().setValue(StringUtils.trimToNull(clinic.getClinicPostal()));
	xad.getAddressType().setValue(addressType);
}
 
Example 33
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 5 votes vote down vote up
public static void fillXAD(XAD xad, Demographic demographic, String country, String addressType) throws DataTypeException {
	xad.getStreetAddress().getStreetOrMailingAddress().setValue(StringUtils.trimToNull(demographic.getAddress()));
	xad.getCity().setValue(StringUtils.trimToNull(demographic.getCity()));
	xad.getStateOrProvince().setValue(StringUtils.trimToNull(demographic.getProvince()));
	if (country != null) xad.getCountry().setValue(StringUtils.trimToNull(country));
	xad.getZipOrPostalCode().setValue(StringUtils.trimToNull(demographic.getPostal()));
	xad.getAddressType().setValue(addressType);
}
 
Example 34
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 5 votes vote down vote up
/**
 * @param sft
 * @param version major version if available
 * @param build build date or build number if available
 */
public static void fillSft(SFT sft, String version, String build) throws DataTypeException {
	sft.getSoftwareVendorOrganization().getOrganizationName().setValue("OSCARMcMaster");
	sft.getSoftwareCertifiedVersionOrReleaseNumber().setValue(version);
	sft.getSoftwareProductName().setValue("OSCAR");
	sft.getSoftwareBinaryID().setValue(build);
}
 
Example 35
Project: OSCAR-ConCert   File: DataTypeUtils.java   Source Code and License 5 votes vote down vote up
/**
 * @param prd
 * @param professionalSpecialist
 * @param providerRoleId Note that this is not the oscar provider role, look in the method to see valid values
 * @param providerRoleDescription Note that this is not the oscar provider role, look in the method to see valid values
 */
public static void fillPrd(PRD prd, ProfessionalSpecialist professionalSpecialist, String providerRoleId, String providerRoleDescription) throws DataTypeException, HL7Exception {
	// Value Description
	// -----------------
	// RP Referring Provider
	// PP Primary Care Provider
	// CP Consulting Provider
	// RT Referred to Provider
	prd.getProviderRole(0).getIdentifier().setValue(providerRoleId);
	prd.getProviderRole(0).getText().setValue(providerRoleDescription);

	XPN xpn = prd.getProviderName(0);
	xpn.getFamilyName().getSurname().setValue(professionalSpecialist.getLastName());
	xpn.getGivenName().setValue(professionalSpecialist.getFirstName());
	xpn.getPrefixEgDR().setValue(professionalSpecialist.getProfessionalLetters());

	XAD xad = prd.getProviderAddress(0);
	xad.getStreetAddress().getStreetOrMailingAddress().setValue(StringUtils.trimToNull(professionalSpecialist.getStreetAddress()));
	xad.getAddressType().setValue("O");

	XTN xtn = prd.getProviderCommunicationInformation(0);
	xtn.getUnformattedTelephoneNumber().setValue(professionalSpecialist.getPhoneNumber());
	xtn.getCommunicationAddress().setValue(professionalSpecialist.getEmailAddress());

	PLN pln = prd.getProviderIdentifiers(0);
	pln.getIDNumber().setValue(professionalSpecialist.getId().toString());
}
 
Example 36
Project: OSCAR-ConCert   File: ChainnedMessageAdapter.java   Source Code and License 5 votes vote down vote up
public String getMsgDate() {
	try {
		DTM dtm = getMsh().getDateTimeOfMessage();
		GregorianCalendar cal = DataTypeUtils.getCalendarFromDTM(dtm);
		return (DateUtils.getISODateTimeFormatNoT(cal));
	} catch (DataTypeException e) {
		logger.error("Unexpected error.", e);
		return (null);
	}
}
 
Example 37
Project: OSCAR-ConCert   File: ChainnedMessageAdapter.java   Source Code and License 5 votes vote down vote up
public String getDOB() {
	try {
		DTM dtm = getPid().getDateTimeOfBirth();
		GregorianCalendar cal = DataTypeUtils.getCalendarFromDTM(dtm);
		
		if (cal==null) return(null);
		
		return (DateUtils.getISODateTimeFormatNoT(cal));
	} catch (DataTypeException e) {
		logger.error("Unexpected Error.", e);
		return (null);
	}
}
 
Example 38
Project: OSCAR-ConCert   File: ChainnedMessageAdapter.java   Source Code and License 5 votes vote down vote up
public String getAge() {
	try {
		DTM dtm = getPid().getDateTimeOfBirth();
		GregorianCalendar cal = DataTypeUtils.getCalendarFromDTM(dtm);
		
		if (cal==null) return(null);
		
		int age = DateUtils.getAge(cal, new GregorianCalendar());
		return (String.valueOf(age));
	} catch (DataTypeException e) {
		logger.error("Unexpected Error.", e);
		return (null);
	}
}
 
Example 39
Project: AvoinApotti   File: VoMapper.java   Source Code and License 5 votes vote down vote up
protected final void renderCommChannelVoCollectionToXTN(CommChannelVoCollection voColl, XTN xtn) throws DataTypeException
{
	if (voColl == null)
		return;
	for (int i=0; i<voColl.size(); i++)
	{
		renderCommChannelVoToXTN(voColl.get(i), xtn);
	}
}
 
Example 40
Project: AvoinApotti   File: VoMapper.java   Source Code and License 5 votes vote down vote up
protected final void renderCommChannelVoToXTN(CommChannelVo vo, XTN xtn) throws DataTypeException
{
	if (vo == null)
		return;
		
	LOG.debug("VoMapper renderCommChannelVoToXTN: entry");
	
	xtn.getAnyText().setValue(vo.getCommValue());
	if (vo.getChannelType().equals(ChannelType.BLEEP))
	{
		xtn.getTelecommunicationEquipmentType().setValue("BP"); 
	}
	else if (vo.getChannelType().equals(ChannelType.EMAIL))
	{
		xtn.getEmailAddress().setValue(vo.getCommValue());
		xtn.getTelecommunicationEquipmentType().setValue("Internet");
		xtn.getTelecommunicationUseCode().setValue("NET");
	}
	else if (vo.getChannelType().equals(ChannelType.FAX))
	{
		xtn.getTelecommunicationEquipmentType().setValue("FX");
	}
	else if (vo.getChannelType().equals(ChannelType.MOBILE) || vo.getChannelType().equals(ChannelType.HOME_PHONE) ||
			vo.getChannelType().equals(ChannelType.WORK_PHONE))
	{
		//xtn.getPhoneNumber().setValue(vo.getCommValue()); 
		xtn.getTelecommunicationEquipmentType().setValue("PH");
	}
			
	LOG.debug("VoMapper renderCommChannelVoToXTN: exit");
}