Narratif généré : StructureMap CorePhysical2FHIR #xD; map "https://interop.aphp.fr/ig/fhir/dm/StructureMap/CorePhysical2FHIR" = "CorePhysical2FHIR"#xD; #xD; // Alignement de l''usage Core du modèle physique du DPI vers les ressources FHIR#xD; #xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreDataSet" alias DataSet as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CorePatient" alias PatientTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreSejour" alias SejourTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreBiology" alias BiologyTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreClinical" alias ClinicalTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreDiag" alias DiagTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreActe" alias ActeTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreAddress" alias AddressTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreMedicationAdm" alias MedicationAdmTable as source#xD; uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/CoreMedicationPre" alias MedicationPreTable as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias FHIRBundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Patient" alias FHIRPatient as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Encounter" alias FHIREncounter as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Observation" alias FHIRObservation as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Meta" alias FHIRMeta as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Procedure" alias FHIRProcedure as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Condition" alias FHIRCondition as target#xD; #xD; group dataSet(source srcDataSet : DataSet, target tgtBundle : FHIRBundle) <<types>> {#xD; srcDataSet -> tgtBundle.id = uuid() "setId";#xD; srcDataSet -> tgtBundle.type = 'transaction' "setType";#xD; srcDataSet.patient as srcPatient -> tgtBundle.entry as tgtPatientEntry, tgtPatientEntry.resource = create('Patient') as newPatient then {#xD; srcPatient then patient(srcPatient, newPatient) "setPatient";#xD; srcPatient then setEntryRequestAndFullUrl(newPatient, tgtPatientEntry) "setRequestAndFullUrl";#xD; srcDataSet.address as srcAddress where patientNi.reference = ('PatientCore/' + %srcPatient.patientNi.toString()) then patientAddress(srcAddress, newPatient) "addPatientAddress";#xD; srcDataSet.sejour as srcSejour where patientNi.reference = ('PatientCore/' + %srcPatient.patientNi.toString()) -> tgtBundle.entry as tgtEncounterEntry, tgtEncounterEntry.resource = create('Encounter') as newEncounter then {#xD; srcSejour then encounter(srcSejour, newPatient, newEncounter) "setEncounter";#xD; srcSejour then setEntryRequestAndFullUrl(newEncounter, tgtEncounterEntry) "setRequestAndFullUrl";#xD; srcDataSet.acte as srcActe where sejourNi.reference = ('SejourCore/' + %srcSejour.sejourNi.toString()) -> tgtBundle.entry as tgtProcedureEntry, tgtProcedureEntry.resource = create('Procedure') as newProcedure then {#xD; srcActe then procedure(srcActe, newPatient, newEncounter, newProcedure) "setProcedure";#xD; srcActe then setEntryRequestAndFullUrl(newProcedure, tgtProcedureEntry) "setRequestAndFullUrl";#xD; } "createProcedure";#xD; srcDataSet.diag as srcDiag where sejourNi.reference = ('SejourCore/' + %srcSejour.sejourNi.toString()) -> tgtBundle.entry as tgtConditionEntry, tgtConditionEntry.resource = create('Condition') as newCondition then {#xD; srcDiag then condition(srcDiag, newPatient, newEncounter, newCondition) "setCondition";#xD; srcDiag then setEntryRequestAndFullUrl(newCondition, tgtConditionEntry) "setRequestAndFullUrl";#xD; } "createProcedure";#xD; srcDataSet.biology as srcBiology where sejourNi.reference = ('SejourCore/' + %srcSejour.sejourNi.toString()) -> tgtBundle.entry as tgtBiologyEntry, tgtBiologyEntry.resource = create('Observation') as newObservation then {#xD; srcBiology then observationBiol(srcBiology, newPatient, newEncounter, newObservation) "setBiology";#xD; srcBiology then setEntryRequestAndFullUrl(newObservation, tgtBiologyEntry) "setRequestAndFullUrl";#xD; } "createObservation";#xD; } "createEncounter";#xD; } "createPatient";#xD; }#xD; #xD; group patient(source srcPatient : PatientTable, target tgtPatient : FHIRPatient) {#xD; srcPatient -> tgtPatient.id = uuid() "setId";#xD; srcPatient.patientNi as srcNi -> tgtPatient.meta as tgtMeta then setPatientMeta(srcNi, tgtMeta) "setMeta"; // copie la valeur du champ patientNi de la table Patient dans l'élément id de la ressource FHIR Patient#xD; srcPatient -> tgtPatient.name as tgtPatientName then setHumainName(srcPatient, tgtPatientName) "setHumainName";#xD; srcPatient -> tgtPatient.identifier as tgtPatientIdentifier then setHumainNir(srcPatient, tgtPatientIdentifier) "setHumainNir";#xD; srcPatient.gender as srcPatientGender -> tgtPatient.gender = translate(srcPatientGender, 'https://interop.aphp.fr/ig/fhir/dm/ConceptMap/DpiGender2Hl7Gender', 'code') "setGender"; // traduit la valeur du champ gender de la table Patient dans l'élément gender de la ressource FHIR Patient#xD; srcPatient.birthDate as srcPatientBirthDate -> tgtPatient.birthDate = srcPatientBirthDate "setBirthDate"; // copie la valeur du champ birthDate de la table Patient dans l'élément birthDate de la ressource FHIR Patient#xD; }#xD; #xD; group setPatientMeta(source srcNi, target tgtMeta : FHIRMeta) {#xD; srcNi -> tgtMeta.source = ('https://aphp.fr/fhir/Endpoint/dpi/PatientTable' + '/' + %srcNi.toString()) "setSource";#xD; }#xD; #xD; group setHumainName(source srcPatient : PatientTable, target tgtPatientName) {#xD; srcPatient -> tgtPatientName.use = 'usual' "setUse";#xD; // srcPatient -> tgtPatientName.text = (%srcPatient.firstName + ' ' + %srcPatient.name) "setText";#xD; // srcPatient.name as srcPatientName -> tgtPatientName.family = srcPatientName "setName";#xD; // srcPatient.firstName as srcPatientFirstName -> tgtPatientName.given = srcPatientFirstName "setFirstName";#xD; // les trois lignes précédentes marchent dans matchbox mais génèrent une erreur au QA. La solution ci dessous marche dans matchbox et ne génère pas d'erreur au QA.#xD; srcPatient.name as srcPatientName -> tgtPatientName.family = srcPatientName then {#xD; srcPatient.firstName as srcPatientFirstName -> tgtPatientName.given = srcPatientFirstName, tgtPatientName.text = (%srcPatientFirstName + ' ' + %srcPatientName) "setFirstNameAndText";#xD; } "setName";#xD; }#xD; #xD; group setHumainNir(source srcPatient : PatientTable, target tgtPatientIdentifier) {#xD; srcPatient.nir as srcPatientNir -> tgtPatientIdentifier.use = 'official', tgtPatientIdentifier.type = cc('https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203', 'INS-NIR'), tgtPatientIdentifier.system = 'urn:oid:1.2.250.1.213.1.4.8', tgtPatientIdentifier.value = srcPatientNir "setNir";#xD; }#xD; #xD; group patientAddress(source srcAddress : AddressTable, target tgtPatient : FHIRPatient) {#xD; srcAddress -> tgtPatient.address = create('Address') as newAddress then {#xD; srcAddress.zipCode as srczip -> newAddress.postalCode = srczip "setZip";#xD; srcAddress.city as srcCity -> newAddress.city = srcCity "setCity";#xD; srcAddress.country as srcCountry -> newAddress.country = srcCountry "setCountry";#xD; srcAddress.address as srcAddressText -> newAddress.text = srcAddressText "setText";#xD; srcAddress where current = true -> newAddress.use = 'home' "setUseHome";#xD; srcAddress where current = false -> newAddress.use = 'old' "setUseOld";#xD; srcAddress where latitude.exists() or longitude.exists() -> newAddress.extension = create('Extension') as firstLevelExtension then {#xD; srcAddress -> firstLevelExtension.url = ('http://hl7.org/fhir/StructureDefinition/geolocation') then {#xD; srcAddress.latitude as srcLat -> firstLevelExtension.extension = create('Extension') as latExtension then {#xD; srcLat -> latExtension.url = ('latitude'), latExtension.value = srcLat "setLat";#xD; } "setLatExt";#xD; srcAddress.longitude as srcLong -> firstLevelExtension.extension = create('Extension') as longExtension then {#xD; srcLong -> longExtension.url = ('longitude'), longExtension.value = srcLong "setLong";#xD; } "setLongExt";#xD; } "setflext";#xD; } "setCoordinatesExtension";#xD; } "setAddress";#xD; }#xD; #xD; group encounter(source srcSejour : SejourTable, source srcPatient : FHIRPatient, target tgtEncounter : FHIREncounter) {#xD; srcSejour -> tgtEncounter.id = uuid() "setId";#xD; srcSejour.sejourNi as srcNi -> tgtEncounter.meta as tgtMeta then setEncounterMeta(srcNi, tgtMeta) "setMeta"; // copie la valeur du champ patientNi de la table Patient dans l'élément id de la ressource FHIR Patient#xD; srcSejour -> tgtEncounter.status = 'finished' "setStatus";#xD; srcSejour.sejourType as srcSejourType -> tgtEncounter.class = translate(srcSejourType, 'https://interop.aphp.fr/ig/fhir/dm/ConceptMap/DpiEncounterType2SemanticLayerEncounterClass', 'Coding') "setEncounterClass";#xD; srcPatient.id as patientId -> tgtEncounter.subject = create('Reference') as newSubject then setSubjectReference(patientId, newSubject) "setSubjectReference";#xD; srcSejour.patientNi; // fk vers le patient à conserver pour la construction auto du périmètre final#xD; srcSejour -> tgtEncounter.period = create('Period') as newActualPeriod then {#xD; srcSejour.sejourStart as srcPeriodStart -> newActualPeriod.start = srcPeriodStart "setStart";#xD; srcSejour.sejourEnd as srcPeriodEnd -> newActualPeriod.end = srcPeriodEnd "setEnd";#xD; } "setPeriod";#xD; }#xD; #xD; group setEncounterMeta(source srcNi, target tgtMeta : FHIRMeta) {#xD; srcNi -> tgtMeta.source = ('https://aphp.fr/fhir/Endpoint/dpi/SejourTable' + '/' + %srcNi.toString()) "setSource";#xD; }#xD; #xD; group setSubjectReference(source srcPatientId, target newSubject) {#xD; srcPatientId -> newSubject.reference = ('Patient/' + %srcPatientId.toString()) "setReference";#xD; }#xD; #xD; group procedure(source srcActe : ActeTable, source srcPatient : FHIRPatient, source srcEncounter : FHIREncounter, target tgtProcedure : FHIRProcedure) {#xD; srcActe -> tgtProcedure.id = uuid() "setId";#xD; srcActe.acteNi as srcNi -> tgtProcedure.meta as tgtMeta then setProcedureMeta(srcNi, tgtMeta) "setMeta";#xD; srcPatient.id as patientId -> tgtProcedure.subject = create('Reference') as newSubject then setSubjectReference(patientId, newSubject) "setSubjectReference";#xD; srcEncounter.id as encounterId -> tgtProcedure.encounter = create('Reference') as newEncounter then setEncounterReference(encounterId, newEncounter) "setEncounterReference";#xD; srcActe -> tgtProcedure.status = 'completed' "setStatus";#xD; srcActe where dateStart.exists() or dateEnd.exists -> tgtProcedure.performed = create('Period') as tgtProcedurePeriod then {#xD; srcActe.dateStart as srcActeStart -> tgtProcedurePeriod.start = srcActeStart "setActeStart";#xD; srcActe.dateEnd as srcActeEnd -> tgtProcedurePeriod.end = srcActeEnd "setActeEnd";#xD; } "setDate";#xD; srcActe.code as acteCode -> tgtProcedure.code = cc('https://smt.esante.gouv.fr/terminologie-ccam', acteCode) "setCode"; // C'est le code de la CCAM facturante#xD; }#xD; #xD; group setProcedureMeta(source srcNi, target tgtMeta : FHIRMeta) {#xD; srcNi -> tgtMeta.source = ('https://aphp.fr/fhir/Endpoint/dpi/ActeTable' + '/' + %srcNi.toString()) "setSource";#xD; }#xD; #xD; group setEncounterReference(source srcEncounterId, target newEncounter) {#xD; srcEncounterId -> newEncounter.reference = ('Encounter/' + %srcEncounterId.toString()) "setReference";#xD; }#xD; #xD; group condition(source srcDiag : DiagTable, source srcPatient : FHIRPatient, source srcEncounter : FHIREncounter, target tgtCondition : FHIRCondition) {#xD; srcDiag -> tgtCondition.id = uuid() "setId";#xD; srcDiag.diagNi as srcNi -> tgtCondition.meta as tgtMeta then setConditionMeta(srcNi, tgtMeta) "setMeta";#xD; srcPatient.id as patientId -> tgtCondition.subject = create('Reference') as newSubject then setSubjectReference(patientId, newSubject) "setSubjectReference";#xD; srcEncounter.id as encounterId -> tgtCondition.encounter = create('Reference') as newEncounter then setEncounterReference(encounterId, newEncounter) "setEncounterReference";#xD; srcDiag -> tgtCondition.verificationStatus = 'confirmed' "setVerificationStatus";#xD; srcDiag -> tgtCondition.category = cc('http://terminology.hl7.org/CodeSystem/condition-category', 'encounter-diagnosis') "setCategory";#xD; srcDiag.code as diagCode -> tgtCondition.code = cc('http://hl7.org/fhir/sid/icd-10', diagCode) "setCode";#xD; }#xD; #xD; group setConditionMeta(source srcNi, target tgtMeta : FHIRMeta) {#xD; srcNi -> tgtMeta.source = ('https://aphp.fr/fhir/Endpoint/dpi/DiagTable' + '/' + %srcNi.toString()) "setSource";#xD; }#xD; #xD; group observationBiol(source srcBiology : BiologyTable, source srcPatient : FHIRPatient, source srcEncounter : FHIREncounter, target tgtObservation : FHIRObservation) {#xD; srcBiology -> tgtObservation.id = uuid() "setId";#xD; srcBiology.biologyNi as srcNi -> tgtObservation.meta as tgtMeta then setBiologyMeta(srcNi, tgtMeta) "setMeta";#xD; srcPatient.id as patientId -> tgtObservation.subject = create('Reference') as newSubject then setSubjectReference(patientId, newSubject) "setSubjectReference";#xD; srcEncounter.id as encounterId -> tgtObservation.encounter = create('Reference') as newEncounter then setEncounterReference(encounterId, newEncounter) "setEncounterReference";#xD; srcBiology -> tgtObservation.status = 'final' "setStatus";#xD; srcBiology -> tgtObservation.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs') "setCategory";#xD; srcBiology.biologyDatePrel as biologyDatePrel -> tgtObservation.effective = biologyDatePrel "setDate";#xD; srcBiology.biologyCode as biologyCode -> tgtObservation.code = cc('http://loinc.org', biologyCode) "setCode";#xD; srcBiology.biologyValue -> tgtObservation.value = create('Quantity') as tgtObsQuantity then {#xD; srcBiology.biologyValue as biologyValue -> tgtObsQuantity.value = biologyValue "setValue";#xD; srcBiology.biologyUnit as biologyUnit -> tgtObsQuantity.code = biologyUnit, tgtObsQuantity.unit = biologyUnit, tgtObsQuantity.system = 'http://unitsofmeasure.org' "setUnit";#xD; } "setQuantity";#xD; }#xD; #xD; group setBiologyMeta(source srcNi, target tgtMeta : FHIRMeta) {#xD; srcNi -> tgtMeta.source = ('https://aphp.fr/fhir/Endpoint/dpi/BiologyTable' + '/' + %srcNi.toString()) "setSource";#xD; }#xD; #xD; group setEntryRequestAndFullUrl(source newRes, target tgtEntry) {#xD; newRes.id as newResId then {#xD; newResId -> tgtEntry.fullUrl = ('https://aphp.fr/' + %newRes.type().name + '/' + %newResId) "setFullUrl";#xD; newResId -> tgtEntry.request as tgtEntryRequest, tgtEntryRequest.method = 'POST', tgtEntryRequest.url = (%newRes.type().name + '/' + %newResId) "setRequest";#xD; } "setResourceType";#xD; }#xD; #xD;
Alignement de l''usage Core du modèle physique du DPI vers les ressources FHIR
patientNi.reference = ('PatientCore/' + %srcPatient.patientNi.toString())
sejourNi.reference = ('SejourCore/' + %srcSejour.sejourNi.toString())
copie la valeur du champ patientNi de la table Patient dans l'élément id de la ressource FHIR Patient
traduit la valeur du champ gender de la table Patient dans l'élément gender de la ressource FHIR Patient
copie la valeur du champ birthDate de la table Patient dans l'élément birthDate de la ressource FHIR Patient
'https://aphp.fr/fhir/Endpoint/dpi/PatientTable' + '/' + %srcNi.toString()
%srcPatientFirstName + ' ' + %srcPatientName
fk vers le patient à conserver pour la construction auto du périmètre final
'https://aphp.fr/fhir/Endpoint/dpi/SejourTable' + '/' + %srcNi.toString()
'https://aphp.fr/fhir/Endpoint/dpi/ActeTable' + '/' + %srcNi.toString()
'Encounter/' + %srcEncounterId.toString()
'https://aphp.fr/fhir/Endpoint/dpi/DiagTable' + '/' + %srcNi.toString()
'https://aphp.fr/fhir/Endpoint/dpi/BiologyTable' + '/' + %srcNi.toString()
'https://aphp.fr/' + %newRes.type().name + '/' + %newResId