我目前有一个功能可以从CCD
中提取患者编号,但CCD
包含MRN, EMPI, SSN
和患者编号。我需要它来提取患者编号而不是EMPI。然后我将使用它来利用RETURN创建一个列。
请帮助!
这是当前代码:
CREATE FUNCTION [dbo].[rs_ExtractPatientIdentifier]
(@xmlData xml, @messageType nvarchar(50))
RETURNS
nvarchar(128)
WITH SCHEMABINDING
BEGIN
DECLARE @patientIdentifier nvarchar(128)
;WITH XMLNAMESPACES(DEFAULT 'http://domain.com/product/Schemas', 'urn:hl7-org:v3' as hl7ns)
SELECT
@patientIdentifier = CASE @messageType
WHEN 'CCD' THEN @xmlData.value('(hl7ns:ClinicalDocument/hl7ns:recordTarget/hl7ns:patientRole/hl7ns:id/@extension)[1]', 'varchar(128)')
WHEN 'PatientAdverseReactionRequest' THEN @xmlData.value('(PatientAdverseReactionRequest/Patient/Identifiers/Identifier/Id)[1]', 'varchar(128)')
WHEN 'UnsolicitedDocumentType' THEN @xmlData.value('(DocumentManagementRequest/Patient/Identifiers/Identifier/Id)[1]', 'varchar(128)')
WHEN 'UnsolicitedLabResult' THEN @xmlData.value('(UnsolicitedLabResult/Patient/Identifiers/Identifier/Id)[1]', 'varchar(128)')
ELSE ''
END
RETURN @patientIdentifier
END
以下是具有患者ID的XML,我需要将其作为本地定义的患者ID:
<ProcessCcdRequest xmlns="http://domain.com/product/Schemas">
<Ccd><ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:sdtc="urn:hl7-org:sdtc" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd"><realmCode code="US"/><typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3"/><templateId root="2.16.840.1.113883.10.20.22.1.1"/><templateId root="2.16.840.1.113883.10.20.22.1.2"/><id root="2.25.126274596634328418155136651226877799755"/><code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Summarization of episode note"/><title>Clinical Document Architecture</title><effectiveTime value="20140619191531-0400"/><confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/><languageCode code="en-US"/><recordTarget><patientRole><id assigningAuthorityName="Enterprise MPI Number" extension="000000001" root="1.3.6.1.4.1.26923.99.1.1.1.2.1"/><id assigningAuthorityName="Enterprise MPI Number" extension="000000001" root="1.3.6.1.4.1.26923.99.1.1.1.2.1"/><id assigningAuthorityName="SSN" extension="999999999" root="2.16.840.1.113883.4.1"/><id assigningAuthorityName="Hospital: Locally defined Patient Account Number" extension="000222222222" root="1.3.6.1.4.1.26923.99.1.1.44273.7.3"/><addr use="HP"><streetAddressLine>111111 Sw 53Rd St</streetAddressLine><city>AnyTown</city><state>FL</state><postalCode>33175</postalCode><country>United States of America</country></addr><telecom use="HP" value="tel:111-222-5555"/><patient><name use="L"><given>Names</given><family>NamesNames</family></name><administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1" codeSystemName="HL7 AdministrativeGenderCodes" displayName="Male"/><birthTime value="19500326"/><maritalStatusCode code="M" codeSystem="2.16.840.1.113883.5.2" codeSystemName="MaritalStatusCode" displayName="Married"/><raceCode code="2106-3" codeSystem="2.16.840.1.113883.6.238" codeSystemName="Race &amp; Ethnicity - CDC" displayName="White Hispanic"/><sdtc:raceCode codeSystem="2.16.840.1.113883.6.238" codeSystemName="Race &amp; Ethnicity - CDC" nullFlavor="NI"/><sdtc:raceCode codeSystem="2.16.840.1.113883.6.238" codeSystemName="Race &amp; Ethnicity - CDC" nullFlavor="NI"/><ethnicGroupCode code="2135-2" codeSystem="2.16.840.1.113883.6.238" codeSystemName="Race &amp; Ethnicity - CDC" displayName="Hispanic"/><languageCommunication><languageCode code="spa"/><preferenceInd value="true"/></languageCommunication></patient><providerOrganization><id assigningAuthorityName="Hospital" extension="Entity: EDA" root="2.16.840.1.114060.6.3.1.4.1"/><name>Hospital</name><telecom use="WP" value="tel:111-111-2222"/><addr use="WP"><streetAddressLine>11111 N 1st Avenue</streetAddressLine><city>AnyTown</city><state>FL</state><postalCode>12345</postalCode><country>United States of America</country></addr></providerOrganization></patientRole></recordTarget><author><time value="20140619191531-0400"/><assignedAuthor><id assigningAuthorityName="NPI" extension="1234567891" root="2.16.840.1.113883.4.6"/><addr><streetAddressLine nullFlavor="NI"/><city nullFlavor="NI"/><state nullFlavor="NI"/><postalCode nullFlavor="NI"/><country nullFlavor="NI"/></addr><telecom value="tel:111-222-4444 ext:"/><assignedPerson><name><given>OthLastNamei</given><family>LastName-Man</family></name></assignedPerson><representedOrganization><id extension="W0CL" root="2.16.840.1.114060.6.3.1.4.1"/><name> Hospital </name><telecom value="tel:111-111-2222"/><addr><streetAddressLine>11111 N 1st Avenue</streetAddressLine><city>AnyTown</city><state>FL</state><postalCode>12345</postalCode><country>United States of America</country></addr></representedOrganization></assignedAuthor></author><custodian><assignedCustodian><representedCustodianOrganization><!-- OID is OID for Custodian hospital name --><id extension="W0CL" root="2.16.840.1.114060.6.3.1.4.1"/><name>Hospital</name><telecom value="tel:111-111-2222"/><addr><streetAddressLine>11111 N 1st Avenue</streetAddressLine><city>AnyTown</city><state>FL</state><postalCode>12345</postalCode><country>United States of America</country></addr></representedCustodianOrganization></assignedCustodian></custodian><documentationOf><serviceEvent classCode="PCPR"><effectiveTime><low value="20140614"/><high value="20140619"/></effectiveTime></serviceEvent></documentationOf><componentOf><encompassingEncounter><id extension="000000123456" root="2.16.840.1.113883.19"/><effectiveTime><low value="201406141743"/><high value="201406191843"/></effectiveTime><encounterParticipant typeCode="CON"><assignedEntity><id assigningAuthorityName="NPI" extension="1111111111" root="2.16.840.1.113883.4.6"/><addr use="WP"><streetAddressLine nullFlavor="NI"/><city nullFlavor="NI"/><state nullFlavor="NI"/><postalCode nullFlavor="NI"/><country nullFlavor="NI"/></addr><telecom use="WP" value="tel:123-123-1234 ext:"> </telecom><assignedPerson><name><given>John J</given><family>Snow</family></name></assignedPerson></assignedEntity></encounterParticipant><encounterParticipant typeCode="ADM"><assignedEntity><id assigningAuthorityName="NPI" extension="1234567891" root="2.16.840.1.113883.4.6"/><addr use="WP"><streetAddressLine nullFlavor="NI"/><city nullFlavor="NI"/><state nullFlavor="NI"/><postalCode nullFlavor="NI"/><country nullFlavor="NI"/></addr><telecom use="WP" value="tel:111-222-4444 ext:"> </telecom><assignedPerson><name><given>OthLastNamei</given><family>LastName-Man</family></name></assignedPerson></assignedEntity></encounterParticipant><encounterParticipant typeCode="ATND"><assignedEntity><id assigningAuthorityName="NPI" extension="1234567891" root="2.16.840.1.113883.4.6"/><addr use="WP"><streetAddressLine nullFlavor="NI"/><city nullFlavor="NI"/><state nullFlavor="NI"/><postalCode nullFlavor="NI"/><country nullFlavor="NI"/></addr><telecom use="WP" value="tel:111-222-4444 ext:"> </telecom><assignedPerson><name><given>OthLastNamei</given><family>LastName-Man</family></name></assignedPerson></assignedEntity></encounterParticipant><location><healthCareFacility><id assigningAuthorityName="Hospital" extension="hosp svc:EDA" root="2.16.840.1.114060.6.3.1.4.1"/><location><name>Inpatient Via Ed-Eda</name><addr use="WP"><streetAddressLine>11111 N 1st Avenue</streetAddressLine><city>AnyTown</city><state>FL</state><postalCode>12345</postalCode><country>United States of America</country></addr></location></healthCareFacility></location></encompassingEncounter></componentOf><component><structuredBody><
为了便于阅读,<Ccd>
元素的内容在未转义(解析)时如下所示:
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:sdtc="urn:hl7-org:sdtc" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd">
<realmCode code="US"/>
<typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3"/>
<templateId root="2.16.840.1.113883.10.20.22.1.1"/>
<templateId root="2.16.840.1.113883.10.20.22.1.2"/>
<id root="2.25.126274596634328418155136651226877799755"/>
<code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Summarization of episode note"/>
<title>Clinical Document Architecture</title>
<effectiveTime value="20140619191531-0400"/>
<confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/>
<languageCode code="en-US"/>
<recordTarget>
<patientRole>
<id assigningAuthorityName="Enterprise MPI Number" extension="000000001" root="1.3.6.1.4.1.26923.99.1.1.1.2.1"/>
<id assigningAuthorityName="Enterprise MPI Number" extension="000000001" root="1.3.6.1.4.1.26923.99.1.1.1.2.1"/>
<id assigningAuthorityName="SSN" extension="999999999" root="2.16.840.1.113883.4.1"/>
<id assigningAuthorityName="Hospital: Locally defined Patient Account Number" extension="000222222222" root="1.3.6.1.4.1.26923.99.1.1.44273.7.3"/>
...
答案 0 :(得分:0)
您的陈述
WHEN 'CCD' THEN @xmlData.value('(hl7ns:ClinicalDocument/hl7ns:recordTarget/
hl7ns:patientRole/hl7ns:id/@extension)[1]', 'varchar(128)')
正如你所说,选择第一个patientRole / id / @扩展名(因为[1]
)。但是你想要本地定义的患者ID,即
<id assigningAuthorityName="Hospital: Locally defined Patient Account Number"
extension="000222222222" root="1.3.6.1.4.1.26923.99.1.1.44273.7.3"/>
因此,您可以根据assigningAuthorityName
属性的值更改WHEN语句的XPath表达式:
WHEN 'CCD' THEN @xmlData.value('(hl7ns:ClinicalDocument/hl7ns:recordTarget/
hl7ns:patientRole/hl7ns:id[
assigningAuthorityName="Hospital: Locally defined Patient Account Number"]/
@extension)[1]', 'varchar(128)')
(分手,所以你不必侧身滚动)。
这将为您提供@extension
为<id>
assigningAuthorityName
的第一个"Hospital: Locally defined Patient Account Number"
的{{1}}。