001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2025 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.test.hl7v2; 011 012import ca.cdr.api.hl7v2.CdrModelClassFactory; 013import ca.cdr.api.model.enm.CodeSystemEnum; 014import ca.cdr.api.util.PublicApiConstants; 015import ca.cdr.test.hl7v2.MinimalHl7v2ToFhirTestData.EncounterData; 016import ca.cdr.test.hl7v2.MinimalHl7v2ToFhirTestData.HospitalData; 017import ca.cdr.test.hl7v2.MinimalHl7v2ToFhirTestData.ObservationData; 018import ca.cdr.test.hl7v2.MinimalHl7v2ToFhirTestData.PatientData; 019import ca.cdr.test.hl7v2.MinimalHl7v2ToFhirTestData.PractitionerData; 020import ca.uhn.fhir.context.FhirContext; 021import ca.uhn.hl7v2.DefaultHapiContext; 022import ca.uhn.hl7v2.HL7Exception; 023import ca.uhn.hl7v2.model.AbstractMessage; 024import ca.uhn.hl7v2.model.AbstractSegment; 025import ca.uhn.hl7v2.model.AbstractType; 026import ca.uhn.hl7v2.model.DataTypeException; 027import ca.uhn.hl7v2.model.Message; 028import ca.uhn.hl7v2.model.Varies; 029import ca.uhn.hl7v2.model.v25.datatype.CE; 030import ca.uhn.hl7v2.model.v25.datatype.CX; 031import ca.uhn.hl7v2.model.v25.datatype.DT; 032import ca.uhn.hl7v2.model.v25.datatype.EI; 033import ca.uhn.hl7v2.model.v25.datatype.NM; 034import ca.uhn.hl7v2.model.v25.datatype.PL; 035import ca.uhn.hl7v2.model.v25.datatype.ST; 036import ca.uhn.hl7v2.model.v25.datatype.TQ; 037import ca.uhn.hl7v2.model.v25.datatype.XAD; 038import ca.uhn.hl7v2.model.v25.datatype.XCN; 039import ca.uhn.hl7v2.model.v25.datatype.XON; 040import ca.uhn.hl7v2.model.v25.datatype.XPN; 041import ca.uhn.hl7v2.model.v25.datatype.XTN; 042import ca.uhn.hl7v2.model.v25.group.ORU_R01_PATIENT_RESULT; 043import ca.uhn.hl7v2.model.v25.group.RAS_O17_ADMINISTRATION; 044import ca.uhn.hl7v2.model.v25.group.RAS_O17_ORDER; 045import ca.uhn.hl7v2.model.v25.group.RDE_O11_ORDER; 046import ca.uhn.hl7v2.model.v25.message.ADT_A01; 047import ca.uhn.hl7v2.model.v25.message.ADT_A03; 048import ca.uhn.hl7v2.model.v25.message.ADT_A06; 049import ca.uhn.hl7v2.model.v25.message.ADT_A09; 050import ca.uhn.hl7v2.model.v25.message.ADT_A21; 051import ca.uhn.hl7v2.model.v25.message.ADT_A39; 052import ca.uhn.hl7v2.model.v25.message.ADT_A45; 053import ca.uhn.hl7v2.model.v25.message.ADT_A54; 054import ca.uhn.hl7v2.model.v25.message.ADT_A60; 055import ca.uhn.hl7v2.model.v25.message.DFT_P03; 056import ca.uhn.hl7v2.model.v25.message.ORM_O01; 057import ca.uhn.hl7v2.model.v25.message.ORU_R01; 058import ca.uhn.hl7v2.model.v25.message.RAS_O17; 059import ca.uhn.hl7v2.model.v25.message.RDE_O11; 060import ca.uhn.hl7v2.model.v25.message.SIU_S12; 061import ca.uhn.hl7v2.model.v25.message.VXU_V04; 062import ca.uhn.hl7v2.model.v25.segment.AIL; 063import ca.uhn.hl7v2.model.v25.segment.AIP; 064import ca.uhn.hl7v2.model.v25.segment.AL1; 065import ca.uhn.hl7v2.model.v25.segment.DG1; 066import ca.uhn.hl7v2.model.v25.segment.FT1; 067import ca.uhn.hl7v2.model.v25.segment.GT1; 068import ca.uhn.hl7v2.model.v25.segment.IAM; 069import ca.uhn.hl7v2.model.v25.segment.IN1; 070import ca.uhn.hl7v2.model.v25.segment.IN2; 071import ca.uhn.hl7v2.model.v25.segment.MRG; 072import ca.uhn.hl7v2.model.v25.segment.MSH; 073import ca.uhn.hl7v2.model.v25.segment.NK1; 074import ca.uhn.hl7v2.model.v25.segment.OBR; 075import ca.uhn.hl7v2.model.v25.segment.OBX; 076import ca.uhn.hl7v2.model.v25.segment.ORC; 077import ca.uhn.hl7v2.model.v25.segment.PD1; 078import ca.uhn.hl7v2.model.v25.segment.PID; 079import ca.uhn.hl7v2.model.v25.segment.PR1; 080import ca.uhn.hl7v2.model.v25.segment.PV1; 081import ca.uhn.hl7v2.model.v25.segment.PV2; 082import ca.uhn.hl7v2.model.v25.segment.ROL; 083import ca.uhn.hl7v2.model.v25.segment.RXA; 084import ca.uhn.hl7v2.model.v25.segment.RXC; 085import ca.uhn.hl7v2.model.v25.segment.RXE; 086import ca.uhn.hl7v2.model.v25.segment.RXR; 087import ca.uhn.hl7v2.model.v25.segment.SCH; 088import ca.uhn.hl7v2.validation.impl.NoValidation; 089 090 091/** 092 * Creates HL7 V2 test data 093 */ 094public class Hl7V2TestDataHelper { 095 096 public static final String FACILITY_SYSTEM = "http://acme.org/facility"; 097 private static DefaultHapiContext ourV2Ctx; 098 private static FhirContext ourContext; 099 100 public Hl7V2TestDataHelper(FhirContext theFhirContext, DefaultHapiContext v2Ctx) { 101 ourContext = theFhirContext; 102 ourV2Ctx = v2Ctx; 103 } 104 105 public static Hl7V2TestDataHelper buildDefault(FhirContext theFhirContext) { 106 ourV2Ctx = new DefaultHapiContext(); 107 ourV2Ctx.setValidationContext(new NoValidation()); 108 ourV2Ctx.setModelClassFactory(new CdrModelClassFactory()); 109 return new Hl7V2TestDataHelper(theFhirContext, ourV2Ctx); 110 } 111 112 public void addExtraComponent(AbstractType theTarget, int theComponentIndex, String theValue) 113 throws DataTypeException { 114 ST system = new ST(theTarget.getMessage()); 115 system.setValue(theValue); 116 theTarget.getExtraComponents().getComponent(theComponentIndex).setData(system); 117 } 118 119 public ADT_A01 createAdtA01() throws HL7Exception { 120 return createAdtA01(true); 121 } 122 123 public ADT_A01 createAdtA01(boolean theValid) throws HL7Exception { 124 ADT_A01 a01 = new ADT_A01(); 125 126 // Patient, family doctor, next of kin, and employer 127 populateMsh(a01.getMSH(), "ADT^A01^ADT_A01"); 128 populatePid(a01.getPID(), theValid); 129 populateNk1NextOfKin(a01.insertNK1(0)); 130 populateNk1Employer(a01.insertNK1(1)); 131 populateRolA(a01.insertROL(0)); 132 133 // Visit, attending, admitting, diagnosis, etc 134 populatePv1(a01.getPV1()); 135 populatePv2(a01.getPV2()); 136 populateRolB(a01.insertROL2(0)); 137 populateRolC(a01.insertROL2(1)); 138 populateDg1(a01.getDG1()); 139 populatePr1First(a01.insertPROCEDURE(0).getPR1()); 140 populateGt1(a01.getGT1()); 141 populateIn1(a01.insertINSURANCE(0).getIN1()); 142 populateIn2(a01.getINSURANCE(0).getIN2()); 143 144 // Assessments 145 populateObxAssessmentWeight(a01, a01.insertOBX(0)); 146 populateObxAssessmentHeight(a01, a01.insertOBX(0)); 147 148 return a01; 149 } 150 151 public ADT_A03 createAdtA03() throws HL7Exception { 152 ADT_A03 a03 = new ADT_A03(); 153 154 // Patient and family doctor 155 populateMsh(a03.getMSH(), "ADT^A03^ADT_A03"); 156 populatePid(a03.getPID()); 157 populateRolA(a03.insertROL(0)); 158 159 // Visit, attending, admitting, diagnosis, etc 160 populatePv1(a03.getPV1()); 161 populateRolB(a03.insertROL2(0)); 162 populateRolC(a03.insertROL2(1)); 163 populateDg1(a03.getDG1(), true); 164 populatePr1First(a03.getPROCEDURE(0).getPR1()); 165 populatePr1Second(a03.getPROCEDURE(1).getPR1()); 166 populateGt1(a03.getGT1()); 167 populateIn1(a03.insertINSURANCE(0).getIN1()); 168 populateIn2(a03.getINSURANCE(0).getIN2()); 169 170 // Assessments (come after DG1 for A03) 171 populateObxAssessmentWeight(a03, a03.insertOBX(0)); 172 populateObxAssessmentHeight(a03, a03.insertOBX(0)); 173 174 return a03; 175 } 176 177 public ADT_A06 createAdtA06() throws HL7Exception { 178 ADT_A06 a06 = new ADT_A06(); 179 180 populateMsh(a06.getMSH(), "ADT^A06^ADT_A06"); 181 populatePid(a06.getPID()); 182 // pd1 183 populateRolA(a06.insertROL(0)); 184 // mrg 185 populateNk1NextOfKin(a06.getNK1()); 186 populatePv1(a06.getPV1()); 187 populatePv2(a06.getPV2()); 188 populateRolB(a06.insertROL2(0)); 189 populateObxAssessmentWeight(a06, a06.insertOBX(0)); 190 populateAl1(a06.getAL1()); 191 populateDg1(a06.getDG1(), true); 192 populatePr1First(a06.getPROCEDURE(0).getPR1()); 193 populateGt1(a06.getGT1()); 194 populateIn1(a06.insertINSURANCE(0).getIN1()); 195 populateIn2(a06.getINSURANCE(0).getIN2()); 196 197 return a06; 198 } 199 200 /** 201 * The ADT^A07 trigger uses the same structure as ADT^A06 (i.e. ADT_A06) 202 */ 203 public ADT_A06 createAdtA07() throws HL7Exception { 204 ADT_A06 adtA07 = createAdtA06(); 205 populateMsh(adtA07.getMSH(), "ADT^A07^ADT_A06"); 206 return adtA07; 207 } 208 209 public ADT_A09 createAdtA10() throws HL7Exception { 210 ADT_A09 a09 = new ADT_A09(); 211 212 // Patient 213 populateMsh(a09.getMSH(), "ADT^A10^ADT_A09"); 214 215 // Visit 216 populatePv1(a09.getPV1()); 217 218 return a09; 219 } 220 221 public ADT_A09 createAdtA11() throws HL7Exception { 222 ADT_A09 a09 = new ADT_A09(); 223 224 // Patient 225 populateMsh(a09.getMSH(), "ADT^A11^ADT_A09"); 226 populatePid(a09.getPID()); 227 228 // Visit 229 populatePv1(a09.getPV1()); 230 populatePv2(a09.getPV2()); 231 232 return a09; 233 } 234 235 public void populateMinimalPatient(PID thePid, PD1 thePd1, PatientData thePatientData) throws HL7Exception { 236 CX pid3 = thePid.insertPid3_PatientIdentifierList(0); 237 pid3.getCx1_IDNumber().setValue(thePatientData.identifier.value); 238 pid3.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue(thePatientData.identifier.system); 239 pid3.getCx5_IdentifierTypeCode().setValue("MR"); 240 241 thePd1.getPd119_MilitaryBranch().setValue(thePatientData.militaryBranch); 242 } 243 244 public void populateMinimalEncounter( 245 PV1 thePv1, 246 PV2 thePv2, 247 EncounterData theEncounter, 248 HospitalData theHospital, 249 PractitionerData thePractitioner) 250 throws HL7Exception { 251 thePv1.getPv12_PatientClass().setValue("E"); // Table 0004 - Emergency 252 253 PL assignedLocation = thePv1.getPv13_AssignedPatientLocation(); 254 assignedLocation.getPl1_PointOfCare().setValue(theHospital.name); 255 assignedLocation 256 .getPl10_ComprehensiveLocationIdentifier() 257 .getEi1_EntityIdentifier() 258 .setValue(theHospital.identifier.value); 259 assignedLocation 260 .getPl10_ComprehensiveLocationIdentifier() 261 .getEi2_NamespaceID() 262 .setValue(theHospital.identifier.system); 263 assignedLocation.getExtraComponents().getComponent(0).getData().parse(FACILITY_SYSTEM); 264 265 XCN practitioner = thePv1.getPv17_AttendingDoctor(0); 266 practitioner.getXcn1_IDNumber().setValue(thePractitioner.identifier.value); 267 practitioner.getXcn9_AssigningAuthority().getHd1_NamespaceID().setValue(thePractitioner.identifier.system); 268 269 CX visitNumber = thePv1.getPv119_VisitNumber(); 270 visitNumber.getCx1_IDNumber().setValue(theEncounter.identifier.value); 271 visitNumber.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue(theEncounter.identifier.system); 272 visitNumber.getCx5_IdentifierTypeCode().setValue("VN"); // Table 0203 - Visit Number 273 274 thePv2.getPv28_ExpectedAdmitDateTime().getTs1_Time().setValue(theEncounter.expectedAdmitTime.v2Date); 275 } 276 277 public void populateMinimalObservation(Message theMessage, OBX theObx, ObservationData theObservationData) 278 throws DataTypeException { 279 theObx.getObx2_ValueType().setValue("ST"); 280 ST obxText = new ST(theMessage); 281 obxText.setValue(theObservationData.text); 282 theObx.getObx5_ObservationValue(0).setData(obxText); 283 284 theObx.getObx3_ObservationIdentifier().getCe1_Identifier().setValue(theObservationData.code); 285 theObx.getObx3_ObservationIdentifier().getCe3_NameOfCodingSystem().setValue(theObservationData.system); 286 287 theObx.getObx11_ObservationResultStatus().setValue(theObservationData.status); 288 theObx.getObx14_DateTimeOfTheObservation().getTs1_Time().setValue(theObservationData.dateTime.v2Date); 289 } 290 291 public ADT_A21 createAdtA29() throws HL7Exception { 292 ADT_A21 a29 = new ADT_A21(); 293 294 populateMsh(a29.getMSH(), "ADT^A29^ADT_A21"); 295 populatePid(a29.getPID()); 296 297 return a29; 298 } 299 300 /** 301 * The ADT^A42 trigger uses the same structure as ADT^A39 (i.e. ADT_A39) 302 */ 303 public ADT_A39 createAdtA42() throws HL7Exception { 304 ADT_A39 adtA42 = new ADT_A39(); 305 populateMsh(adtA42.getMSH(), "ADT^A42^ADT_A39"); 306 populatePid(adtA42.getPATIENT().getPID()); 307 308 populateMrg(adtA42.getPATIENT().getMRG()); 309 populatePv1(adtA42.getPATIENT().getPV1()); 310 return adtA42; 311 } 312 313 public ADT_A45 createAdtA45() throws HL7Exception { 314 ADT_A45 adtA45 = new ADT_A45(); 315 populateMsh(adtA45.getMSH(), "ADT^A45^ADT_A45"); 316 populatePid(adtA45.getPID()); 317 318 populateMrg(adtA45.getMERGE_INFO().getMRG()); 319 populatePv1(adtA45.getMERGE_INFO().getPV1()); 320 321 return adtA45; 322 } 323 324 public ADT_A54 createAdtA54() throws HL7Exception { 325 ADT_A54 adtA54 = new ADT_A54(); 326 327 // Patient and family doctor 328 populateMsh(adtA54.getMSH(), "ADT^A54^ADT_A54"); 329 populatePid(adtA54.getPID()); 330 populateRolA(adtA54.insertROL(0)); 331 332 // Visit, attending, admitting, diagnosis, etc 333 populatePv1(adtA54.getPV1()); 334 populateRolB(adtA54.insertROL2(0)); 335 populateRolC(adtA54.insertROL2(1)); 336 337 return adtA54; 338 } 339 340 public ADT_A60 createAdtA60() throws HL7Exception { 341 return createAdtA60(false); 342 } 343 344 public ADT_A60 createAdtA60(boolean thePopulateEncounterFields) throws HL7Exception { 345 ADT_A60 a60 = new ADT_A60(); 346 347 populateMsh(a60.getMSH(), "ADT^A60^ADT_A01"); 348 populatePid(a60.getPID()); 349 populateIam(a60.getIAM(0)); 350 351 if (thePopulateEncounterFields) { 352 populatePv1(a60.getPV1()); 353 populatePv2(a60.getPV2()); 354 } 355 356 return a60; 357 } 358 359 public DFT_P03 createDftP03() throws HL7Exception { 360 DFT_P03 p03 = new DFT_P03(); 361 362 populateMsh(p03.getMSH(), "DFT^P03^DFT_P03"); 363 populatePid(p03.getPID()); 364 365 FT1 ft1 = p03.getFINANCIAL().getFT1(); 366 ft1.getFt11_SetIDFT1().setValue("1"); 367 ft1.getFt12_TransactionID().setValue("1133"); 368 addExtraComponent(ft1.getFt12_TransactionID(), 0, "http://transaction-ids"); 369 ft1.getFt13_TransactionBatchID().setValue("9999"); 370 ft1.getFt14_TransactionDate().getDr1_RangeStartDateTime().parse("20150325000000-0000"); 371 ft1.getFt14_TransactionDate().getDr2_RangeEndDateTime().parse("20150326000000-0000"); 372 ft1.getFt16_TransactionType().setValue("CG"); 373 ft1.getFt18_TransactionDescription().setValue("Consultation-Level 4"); 374 ft1.getFt110_TransactionQuantity().setValue("4"); 375 ft1.getFt116_AssignedPatientLocation().getPl1_PointOfCare().setValue("Acme Hospital"); 376 ft1.getFt116_AssignedPatientLocation().getPl2_Room().setValue("3rd Floor Room 124"); 377 ft1.getFt116_AssignedPatientLocation().getPl3_Bed().setValue("6"); 378 ft1.getFt116_AssignedPatientLocation() 379 .getPl4_Facility() 380 .getHd1_NamespaceID() 381 .setValue("Acme Facility"); 382 ft1.getFt116_AssignedPatientLocation().getPl9_LocationDescription().setValue("The Acme Hospital"); 383 ft1.getFt116_AssignedPatientLocation() 384 .getPl10_ComprehensiveLocationIdentifier() 385 .getEi1_EntityIdentifier() 386 .setValue("Acme H"); 387 ft1.getFt116_AssignedPatientLocation() 388 .getPl10_ComprehensiveLocationIdentifier() 389 .getEi2_NamespaceID() 390 .setValue("http://acme.org/wards"); 391 392 ft1.getFt120_PerformedByCode(0).getXcn1_IDNumber().setValue("666"); 393 ft1.getFt120_PerformedByCode(0).getXcn2_FamilyName().getFn1_Surname().setValue("Dinosaur"); 394 ft1.getFt120_PerformedByCode(0).getXcn3_GivenName().setValue("Frances"); 395 ft1.getFt120_PerformedByCode(0) 396 .getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof() 397 .setValue("Frannie"); 398 ft1.getFt120_PerformedByCode(0) 399 .getXcn9_AssigningAuthority() 400 .getHd1_NamespaceID() 401 .setValue("http://acme.org/clinicians"); 402 403 ft1.getFt120_PerformedByCode(1).getXcn1_IDNumber().setValue("666"); 404 ft1.getFt120_PerformedByCode(1).getXcn2_FamilyName().getFn1_Surname().setValue("Dinosaur"); 405 ft1.getFt120_PerformedByCode(1).getXcn3_GivenName().setValue("Frances"); 406 ft1.getFt120_PerformedByCode(1) 407 .getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof() 408 .setValue("Frannie"); 409 ft1.getFt120_PerformedByCode(1) 410 .getXcn9_AssigningAuthority() 411 .getHd1_NamespaceID() 412 .setValue("http://acme.org/clinicians"); 413 414 ft1.getFt121_OrderedByCode(0).getXcn1_IDNumber().setValue("555"); 415 ft1.getFt121_OrderedByCode(0).getXcn2_FamilyName().getFn1_Surname().setValue("Giraffe"); 416 ft1.getFt121_OrderedByCode(0).getXcn3_GivenName().setValue("Longneck"); 417 ft1.getFt121_OrderedByCode(0) 418 .getXcn9_AssigningAuthority() 419 .getHd1_NamespaceID() 420 .setValue("http://acme.org/clinicians"); 421 422 populatePr1First(p03.getFINANCIAL().getFINANCIAL_PROCEDURE().getPR1()); 423 populateDg1(p03.getDG1()); 424 425 populateIn1(p03.getINSURANCE().getIN1()); 426 populateIn2(p03.getINSURANCE().getIN2()); 427 428 return p03; 429 } 430 431 public ORM_O01 createOrmO01() throws HL7Exception { 432 ORM_O01 orm = new ORM_O01(); 433 434 populateMsh(orm.getMSH(), "ORM^O01^ORM_O01"); 435 436 // PATIENT 437 populatePid(orm.getPATIENT().getPID(), true); 438 populatePv1(orm.getPATIENT().getPATIENT_VISIT().getPV1()); 439 populateIn1(orm.getPATIENT().getINSURANCE().getIN1()); // Mapped to Organizaion 440 populateIn2(orm.getPATIENT().getINSURANCE().getIN2()); // Mapped to extension on the Patient 441 populateGt1(orm.getPATIENT().getGT1()); // Mapped to RelatedPerson 442 populateDg1(orm.getORDER(0).getORDER_DETAIL().getDG1()); 443 orm.getORDER(0) 444 .getORDER_DETAIL() 445 .getDG1() 446 .getDg13_DiagnosisCodeDG1() 447 .getCe1_Identifier() 448 .setValue("193462001"); 449 orm.getORDER(0) 450 .getORDER_DETAIL() 451 .getDG1() 452 .getDg13_DiagnosisCodeDG1() 453 .getCe2_Text() 454 .setValue("Insomnia"); 455 orm.getORDER(0).getORDER_DETAIL().getDG1().getDg16_DiagnosisType().setValue("Tentative"); 456 457 XCN dg116 = orm.getORDER(0).getORDER_DETAIL().getDG1().insertDg116_DiagnosingClinician(0); 458 populateXcn(dg116); 459 460 orm.getORDER(0) 461 .getORDER_DETAIL() 462 .getDG1() 463 .getDg120_DiagnosisIdentifier() 464 .getEi1_EntityIdentifier() 465 .setValue("0000000042"); 466 orm.getORDER(0) 467 .getORDER_DETAIL() 468 .getDG1() 469 .getDg120_DiagnosisIdentifier() 470 .getEi2_NamespaceID() 471 .setValue("http://acme.org/diagnosis-identifiers"); 472 473 // ORDER 474 ORC orc = orm.getORDER().getORC(); // Mapped to DiagnosticOrder 475 orc.getOrc1_OrderControl().setValue("NW"); 476 477 EI orc2 = orc.getOrc2_PlacerOrderNumber(); 478 orc2.getEi1_EntityIdentifier().setValue("12345"); 479 orc2.getEi2_NamespaceID().setValue("http://acme.org/diagnosticOrderIds"); 480 481 orc.getOrc4_PlacerGroupNumber().getEi1_EntityIdentifier().setValue("123"); 482 orc.getOrc4_PlacerGroupNumber().getEi2_NamespaceID().setValue("http://foo"); 483 484 orc.getOrc7_QuantityTiming(0).getTq4_StartDateTime().getTs1_Time().setValue("20160210111213-0400"); 485 486 XCN orc12 = orc.insertOrc12_OrderingProvider(0); 487 populateXcn(orc12); 488 489 OBR obr = orm.getORDER().getORDER_DETAIL().getOBR(); // Mapped to DiagnosticReport 490 491 EI obr2 = obr.getObr2_PlacerOrderNumber(); 492 obr2.getEi1_EntityIdentifier().setValue("54321"); 493 obr2.getEi2_NamespaceID().setValue("http://acme.org/diagnosticIds"); 494 495 CE obr4 = obr.getObr4_UniversalServiceIdentifier(); 496 obr4.getCe1_Identifier().setValue("5500-1"); 497 obr4.getCe2_Text().setValue("Blood Panel"); 498 obr4.getCe3_NameOfCodingSystem().setValue("http://acme.org/diagnosticCodes"); 499 500 obr.getObr7_ObservationDateTime().getTs1_Time().setValue("201602131000-0400"); 501 obr.getObr8_ObservationEndDateTime().getTs1_Time().setValue("201602131100-0400"); 502 obr.getObr22_ResultsRptStatusChngDateTime().getTs1_Time().setValue("2017081312-0500"); 503 obr.getObr25_ResultStatus().setValue("F"); 504 obr.getObr27_QuantityTiming(0).getTq6_Priority().setValue("stat"); 505 506 populateDg1(orm.getORDER(0).getORDER_DETAIL().getDG1()); // Mapped to Condition 507 508 // Observation stuff 509 ca.uhn.hl7v2.model.v25.group.ORM_O01_OBSERVATION order; 510 order = orm.getORDER(0).getORDER_DETAIL().getOBSERVATION(); 511 order.getOBX().getObx2_ValueType().setValue("NM"); 512 order.getOBX().getObx3_ObservationIdentifier().getCe1_Identifier().setValue("9477-3"); 513 order.getOBX().getObx3_ObservationIdentifier().getCe2_Text().setValue("Sodium (Plasma)"); 514 order.getOBX() 515 .getObx3_ObservationIdentifier() 516 .getCe3_NameOfCodingSystem() 517 .setValue("http://acme.org/observationCodes"); 518 NM nm = new NM(orm); 519 nm.setValue("150"); 520 order.getOBX().insertObx5_ObservationValue(0).setData(nm); 521 order.getOBX().getObx6_Units().getCe1_Identifier().setValue("mmol/L"); 522 order.getOBX().getObx6_Units().getCe2_Text().setValue("mmol/Liter"); 523 order.getOBX().getObx6_Units().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.CODE_SYSTEM_UCUM); 524 order.getOBX().getObx7_ReferencesRange().setValue("0.2-333"); 525 order.getOBX().getObx11_ObservationResultStatus().setValue("F"); 526 527 CE obx15 = order.getOBX().getObx15_ProducerSID(); 528 obx15.getCe1_Identifier().setValue("3141592"); 529 obx15.getCe3_NameOfCodingSystem().setValue("http://acme.org/facility"); 530 531 XCN obx16 = order.getOBX().getObx16_ResponsibleObserver(0); 532 populateXcn(obx16); 533 534 order.getOBX().getObx19_DateTimeOfTheAnalysis().getTs1_Time().setValue("20110202112233+0100"); 535 536 Varies obx23 = (Varies) order.getOBX().getField(23, 0); 537 obx23.parse("Acme Facility"); 538 539 Varies obx24 = (Varies) order.getOBX().getField(24, 0); 540 obx24.parse("342 Evergreen Terrace^2nd Floor^Springfield^NI^12345^USA^B^^Awesome Town"); 541 542 return orm; 543 } 544 545 public ORU_R01 createOruR01() throws HL7Exception { 546 ORU_R01 r01 = new ORU_R01(); 547 r01.setParser(ourV2Ctx.getPipeParser()); 548 549 r01.getMSH().getMsh1_FieldSeparator().setValue("|"); 550 r01.getMSH().getMsh2_EncodingCharacters().setValue("^~\\&"); 551 r01.getMSH().getMsh3_SendingApplication().getHd1_NamespaceID().setValue("http://acme.org/application"); 552 r01.getMSH().getMsh3_SendingApplication().getHd2_UniversalID().setValue("ACME Application"); 553 r01.getMSH().getMsh4_SendingFacility().getHd1_NamespaceID().setValue("http://acme.org/facility"); 554 r01.getMSH().getMsh4_SendingFacility().getHd2_UniversalID().setValue("Acme Facility"); 555 r01.getMSH().getMsh9_MessageType().parse("ORU^R01^ORU_R01"); 556 r01.getMSH().getMsh10_MessageControlID().setValue("A001"); 557 r01.getMSH().getMsh11_ProcessingID().parse("T"); 558 r01.getMSH().getMsh12_VersionID().parse("2.5"); 559 560 ORU_R01_PATIENT_RESULT patientResult = r01.insertPATIENT_RESULT(0); 561 populatePid(patientResult.getPATIENT().getPID()); 562 populatePv1(patientResult.getPATIENT().getVISIT().getPV1()); 563 564 ORC orc = patientResult.getORDER_OBSERVATION().getORC(); 565 orc.getOrc1_OrderControl().setValue("NW"); 566 567 EI orc2 = orc.getOrc2_PlacerOrderNumber(); 568 orc2.getEi1_EntityIdentifier().setValue("12345"); 569 orc2.getEi2_NamespaceID().setValue("http://acme.org/diagnosticOrderIds"); 570 571 orc.getOrc4_PlacerGroupNumber().getEi1_EntityIdentifier().setValue("123"); 572 orc.getOrc4_PlacerGroupNumber().getEi2_NamespaceID().setValue("http://foo"); 573 574 orc.getOrc7_QuantityTiming(0).getTq4_StartDateTime().getTs1_Time().setValue("20160210111213-0400"); 575 576 XCN orc12 = orc.insertOrc12_OrderingProvider(0); 577 populateXcn(orc12); 578 579 OBR obr = patientResult.getORDER_OBSERVATION().getOBR(); 580 581 EI obr2 = obr.getObr2_PlacerOrderNumber(); 582 obr2.getEi1_EntityIdentifier().setValue("54321"); 583 obr2.getEi2_NamespaceID().setValue("http://acme.org/diagnosticIds"); 584 585 CE obr4 = obr.getObr4_UniversalServiceIdentifier(); 586 obr4.getCe1_Identifier().setValue("5500-1"); 587 obr4.getCe2_Text().setValue("Blood Panel"); 588 obr4.getCe3_NameOfCodingSystem().setValue("http://acme.org/diagnosticCodes"); 589 590 obr.getObr7_ObservationDateTime().getTs1_Time().setValue("201602131000-0400"); 591 obr.getObr8_ObservationEndDateTime().getTs1_Time().setValue("201602131100-0400"); 592 obr.getObr22_ResultsRptStatusChngDateTime().getTs1_Time().setValue("2017081312-0500"); 593 obr.getObr25_ResultStatus().setValue("F"); 594 obr.getObr27_QuantityTiming(0).getTq6_Priority().setValue("stat"); 595 596 patientResult.getORDER_OBSERVATION().getNTE(0).insertNte3_Comment(0).setValue("Comment Line 1"); 597 patientResult.getORDER_OBSERVATION().getNTE(0).insertNte3_Comment(1).setValue("Comment Line 2"); 598 patientResult.getORDER_OBSERVATION().getNTE(1).insertNte3_Comment(0).setValue("Comment Line 3"); 599 patientResult.getORDER_OBSERVATION().getNTE(2).insertNte3_Comment(0).parse("Comment Line 4a & Comment Line 4b"); 600 601 ca.uhn.hl7v2.model.v25.group.ORU_R01_OBSERVATION observation; 602 observation = patientResult 603 .getORDER_OBSERVATION() 604 .insertOBSERVATION(patientResult.getORDER_OBSERVATION().getOBSERVATIONReps()); 605 observation.getOBX().getObx2_ValueType().setValue("NM"); 606 observation.getOBX().getObx3_ObservationIdentifier().getCe1_Identifier().setValue("9477-3"); 607 observation.getOBX().getObx3_ObservationIdentifier().getCe2_Text().setValue("Sodium (Plasma)"); 608 observation 609 .getOBX() 610 .getObx3_ObservationIdentifier() 611 .getCe3_NameOfCodingSystem() 612 .setValue("http://acme.org/observationCodes"); 613 NM nm = new NM(r01); 614 nm.setValue("150"); 615 observation.getOBX().insertObx5_ObservationValue(0).setData(nm); 616 observation.getOBX().getObx6_Units().getCe1_Identifier().setValue("mmol/L"); 617 observation.getOBX().getObx6_Units().getCe2_Text().setValue("mmol/Liter"); 618 observation.getOBX().getObx6_Units().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.CODE_SYSTEM_UCUM); 619 observation.getOBX().getObx7_ReferencesRange().setValue("0.2-333"); 620 observation.getOBX().getObx11_ObservationResultStatus().setValue("F"); 621 622 CE obx15 = observation.getOBX().getObx15_ProducerSID(); 623 obx15.getCe1_Identifier().setValue("3141592"); 624 obx15.getCe3_NameOfCodingSystem().setValue("http://acme.org/facility"); 625 626 XCN obx16 = observation.getOBX().getObx16_ResponsibleObserver(0); 627 populateXcn(obx16); 628 629 observation.getOBX().getObx19_DateTimeOfTheAnalysis().getTs1_Time().setValue("20110202112233+0100"); 630 631 Varies obx23 = (Varies) observation.getOBX().getField(23, 0); 632 obx23.parse("Acme Facility"); 633 634 Varies obx24 = (Varies) observation.getOBX().getField(24, 0); 635 obx24.parse("342 Evergreen Terrace^2nd Floor^Springfield^NI^12345^USA^B^^Awesome Town"); 636 637 observation = patientResult 638 .getORDER_OBSERVATION() 639 .insertOBSERVATION(patientResult.getORDER_OBSERVATION().getOBSERVATIONReps()); 640 observation.getOBX().getObx2_ValueType().setValue("DT"); 641 observation.getOBX().getObx3_ObservationIdentifier().getCe1_Identifier().setValue("3472-2"); 642 observation.getOBX().getObx3_ObservationIdentifier().getCe2_Text().setValue("Fasting Date"); 643 observation 644 .getOBX() 645 .getObx3_ObservationIdentifier() 646 .getCe3_NameOfCodingSystem() 647 .setValue("http://acme.org/observationCodes"); 648 DT dt = new DT(r01); 649 dt.setValue("20160213"); 650 observation.getOBX().insertObx5_ObservationValue(0).setData(dt); 651 observation.getOBX().getObx11_ObservationResultStatus().setValue("F"); 652 observation.getOBX().getObx14_DateTimeOfTheObservation().getTs1_Time().setValue("20160101121314.1234-0400"); 653 observation.getNTE(0).insertNte3_Comment(0).setValue("Comment Line 1"); 654 observation.getNTE(0).insertNte3_Comment(1).setValue("Comment Line 2"); 655 observation.getNTE(1).insertNte3_Comment(0).setValue("Comment Line 3"); 656 observation.getNTE(2).insertNte3_Comment(0).parse("Comment Line 4a & Comment Line 4b"); 657 658 obx15 = observation.getOBX().getObx15_ProducerSID(); 659 obx15.getCe1_Identifier().setValue("3141592"); 660 obx15.getCe3_NameOfCodingSystem().setValue("http://acme.org/facility"); 661 662 obx23 = (Varies) observation.getOBX().getField(23, 0); 663 obx23.parse("Acme Facility"); 664 665 obx24 = (Varies) observation.getOBX().getField(24, 0); 666 obx24.parse("342 Evergreen Terrace^2nd Floor^Springfield^NI^12345^USA^B^^Awesome Town"); 667 668 // Some OBX String lines 669 670 observation = patientResult 671 .getORDER_OBSERVATION() 672 .insertOBSERVATION(patientResult.getORDER_OBSERVATION().getOBSERVATIONReps()); 673 observation.getOBX().getObx2_ValueType().setValue("ST"); 674 observation.getOBX().getObx3_ObservationIdentifier().getCe1_Identifier().setValue("17464-1"); 675 observation.getOBX().getObx3_ObservationIdentifier().getCe2_Text().setValue("Text Comment"); 676 observation 677 .getOBX() 678 .getObx3_ObservationIdentifier() 679 .getCe3_NameOfCodingSystem() 680 .setValue("http://acme.org/observationCodes"); 681 ST st = new ST(r01); 682 st.setValue("line 1"); 683 observation.getOBX().insertObx5_ObservationValue(0).setData(st); 684 st = new ST(r01); 685 st.setValue("line 2"); 686 observation.getOBX().insertObx5_ObservationValue(1).setData(st); 687 688 obx15 = observation.getOBX().getObx15_ProducerSID(); 689 obx15.getCe1_Identifier().setValue("3141592"); 690 obx15.getCe3_NameOfCodingSystem().setValue("http://acme.org/facility"); 691 692 obx23 = (Varies) observation.getOBX().getField(23, 0); 693 obx23.parse("Acme Facility"); 694 695 obx24 = (Varies) observation.getOBX().getField(24, 0); 696 obx24.parse("342 Evergreen Terrace^2nd Floor^Springfield^NI^12345^USA^B^^Awesome Town"); 697 698 observation = patientResult 699 .getORDER_OBSERVATION() 700 .insertOBSERVATION(patientResult.getORDER_OBSERVATION().getOBSERVATIONReps()); 701 observation.getOBX().getObx2_ValueType().setValue("ST"); 702 observation.getOBX().getObx3_ObservationIdentifier().getCe1_Identifier().setValue("17464-1"); 703 observation.getOBX().getObx3_ObservationIdentifier().getCe2_Text().setValue("Text Comment"); 704 observation 705 .getOBX() 706 .getObx3_ObservationIdentifier() 707 .getCe3_NameOfCodingSystem() 708 .setValue("http://acme.org/observationCodes"); 709 st = new ST(r01); 710 st.setValue("line 3"); 711 observation.getOBX().insertObx5_ObservationValue(0).setData(st); 712 st = new ST(r01); 713 st.setValue("line 4"); 714 observation.getOBX().insertObx5_ObservationValue(1).setData(st); 715 716 obx15 = observation.getOBX().getObx15_ProducerSID(); 717 obx15.getCe1_Identifier().setValue("3141592"); 718 obx15.getCe3_NameOfCodingSystem().setValue("http://acme.org/facility"); 719 720 obx23 = (Varies) observation.getOBX().getField(23, 0); 721 obx23.parse("Acme Facility"); 722 723 obx24 = (Varies) observation.getOBX().getField(24, 0); 724 obx24.parse("342 Evergreen Terrace^2nd Floor^Springfield^NI^12345^USA^B^^Awesome Town"); 725 726 return r01; 727 } 728 729 public RDE_O11 createRdeO11() throws HL7Exception { 730 return createRdeO11(false); 731 } 732 733 public RDE_O11 createRdeO11(boolean hasMultipleComponents) throws HL7Exception { 734 return createRdeO11(hasMultipleComponents, true); 735 } 736 737 public RDE_O11 createRdeO11(boolean hasMultipleComponents, boolean bothComponentsAreCoded) throws HL7Exception { 738 RDE_O11 rde = new RDE_O11(); 739 populateMsh(rde.getMSH(), "RDE^O11^RDE_O11"); 740 populatePid(rde.getPATIENT().getPID(), true); 741 populatePv1(rde.getPATIENT().getPATIENT_VISIT().getPV1()); 742 743 RDE_O11_ORDER order = rde.insertORDER(0); 744 ORC orc = order.getORC(); 745 populateOrcForMedication(orc, "NW", true, false); 746 747 RXE rxe = order.getRXE(); 748 populateRxe(rxe); 749 750 RXR rxr = order.getRXR(); 751 populateRxr(rxr); 752 753 RXC rxc = order.insertRXC(0); 754 rxc.getRxc1_RXComponentType().setValue("A"); 755 rxc.getRxc2_ComponentCode().getCe1_Identifier().setValue("MEW"); 756 rxc.getRxc2_ComponentCode().getCe2_Text().setValue("Kittens"); 757 rxc.getRxc2_ComponentCode().getCe3_NameOfCodingSystem().setValue("http://acme.org/cats"); 758 rxc.getRxc3_ComponentAmount().setValue("0.5"); 759 rxc.getRxc4_ComponentUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 760 761 if (hasMultipleComponents) { 762 if (bothComponentsAreCoded) { 763 rxc = order.insertRXC(1); 764 rxc.getRxc1_RXComponentType().setValue("B"); 765 rxc.getRxc2_ComponentCode().getCe1_Identifier().setValue("WAF"); 766 rxc.getRxc2_ComponentCode().getCe2_Text().setValue("Puppies"); 767 rxc.getRxc2_ComponentCode().getCe3_NameOfCodingSystem().setValue("http://acme.org/dogs"); 768 rxc.getRxc3_ComponentAmount().setValue("0.3"); 769 rxc.getRxc4_ComponentUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 770 } else { 771 rxc = order.insertRXC(1); 772 rxc.getRxc2_ComponentCode().getCe2_Text().setValue("Duckies"); 773 rxc.getRxc3_ComponentAmount().setValue("0.2"); 774 rxc.getRxc4_ComponentUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 775 } 776 } 777 778 return rde; 779 } 780 781 public SIU_S12 createSiuS12() throws HL7Exception { 782 783 /* Sample from NEMS 784 MSH|^~\&|NextGen Rosetta|NextGen Clinic^0001|Billing System|Billing System|20201215094458188||SIU^S14|365776434|P|2.5 785 SCH|5617679^5617679|5617679^5617679||||79c7e354-8743-47ed-b8ca-66c4308c55ff^Follow Up 15 Min|^Smile API Testing Details|79c7e354-8743-47ed-b8ca-66c4308c55ff^Follow Up 15 Min|15|minutes|^^^202012150945^202012151000|||||1562^CDR^Smile||||1562^CDR^Smile|||||KEPT 786 PID|1|000001084399|312759||Test^Xiuming||20000401|M||11111111-1234-5678-3333-111122223333^Declined to specify|123 Smile Ave^^San Francisco^CA^94112^4c370504-8471-4303-a04b-200a31015e17^^^121cbd16-ba04-4d58-ac09-9ada6474505b||4152223333||^eng^|||||||78860700-68ed-4c0f-bf10-b6a522831ae4^Other||||||||N 787 PV1|1|O|ab8af01a-fbcc-4ead-9b24-8bac014f413b||||bd1a5a82-6dee-4a8a-8059-37e8db475b1e^Smile PROV^Demo|||||||||||||||||||||||||||||||||||||202012150944||||||c9fb567a-e4e5-4e2e-a042-23db78859880 788 AIL|1|A|ab8af01a-fbcc-4ead-9b24-8bac014f413b^San Bruno Adult NEMS^San Bruno 1 Medical|^Place||202012150945||||||KEPT 789 AIP|1|A|bd1a5a82-6dee-4a8a-8059-37e8db475b1e^Smile PROV^Demo|P^Attending||202012150945||||||KEPT 790 AIP|2|A|e1e79ce3-070b-48eb-b898-dc498f6efcaa^Abstracted^Med|S^Resource||202012150945||||||KEPT 791 NTE||{"formSet":[{"formLabel":"nems-instructions"},{"formLabel":"nems-phq9"},{"formLabel":"nems-bhs"},{"formLabel":"nems-gad7"}]}|20^8^14||+Smile API Testing 792 */ 793 794 SIU_S12 siu = new SIU_S12(); 795 796 populateMsh(siu.getMSH(), "SIU^S12^SIU_S12"); 797 798 populateSch(siu.getSCH()); 799 populateAil(siu.getRESOURCES().getLOCATION_RESOURCE().getAIL()); 800 populateAip(siu.getRESOURCES().getPERSONNEL_RESOURCE().getAIP()); 801 802 populatePv1(siu.getPATIENT().getPV1()); 803 populatePid(siu.getPATIENT().getPID(), true); 804 805 return siu; 806 } 807 808 public VXU_V04 createVxuV04() throws HL7Exception { 809 VXU_V04 vxu = new VXU_V04(); 810 811 // Patient, family doctor, next of kin, and employer 812 populateMsh(vxu.getMSH(), "VXU^V04^VXU_V04"); 813 populatePid(vxu.getPID(), true); 814 815 ORC orc = vxu.getORDER().getORC(); 816 orc.getOrc1_OrderControl().setValue("RE"); 817 orc.getOrc2_PlacerOrderNumber().getEi1_EntityIdentifier().setValue("0001"); 818 orc.getOrc2_PlacerOrderNumber().getEi2_NamespaceID().setValue("http://acme.org/vaxorders"); 819 820 XCN orc12 = orc.insertOrc12_OrderingProvider(0); 821 populateXcn(orc12); 822 823 /* 824 Sample from MUSC 825 826 MSH|^~\&|EPIC|SC378274|SIMON|SIMON|20210202071234-0500|NOF200|VXU^V04^VXU_V04|878162|P|2.5.1|||ER|AL|||||Z22^CDCPHINVS|| 827 PID|1||009999901^^^MRN^MR||TESTER^NICK^^^^^L||19810724|M|||55 FAKE STREET^^CHARLESTON^SC^29401^US^P^^| |^PRN^PH^^1^865^5551212~^NET^Internet^npappageorgio@gmail.com|||||9950381520||||||N||||||N|| 828 ORC|RE|228878084^MUSC_EPIC|16306934^MUSC||||||20210202071216-0500|NOF200^FLEISCHMANN^NOELLE^^^^^^MUSCNetID||1871601732^SCHEURER^DANIELLE^B.^^^^^MUSC_EPIC^^^^PNPI|^^^MUSC RUTLEDGE TOWER&SC378274&IMM^^^^^|^^^^1^843^7922300^^||||58D99F5F5D8CD6502783D9901B5E1ECDA83173F1^ROVER IOS 144|||||||||||I| 829 RXA|0|1|20210202|20210202|208^COVID-19, MRNA, LNP-S, PF, 30 MCG/0.3 ML^CVX|30|mcg^micrograms^UCUM||00^New immunization record^NIP001~^VIS date: 12/01/2020~~~|NOF200^FLEISCHMANN^NOELLE^^^^^^MUSCNetID|^^^MUSC RUTLEDGE TOWER&SC378274&IMM^^^^^||||EN9581|20210502|PFR^Pfizer, Inc^MVX|||CP|A|20210202071234-0500|||||| 830 RXR|IM^Intramuscular^HL70162|LD^Left deltoid^HL70163 831 OBX|1|CE|30956-7^Vaccine Type^LN|1|208^COVID-19, MRNA, LNP-S, PF, 30 MCG/0.3 ML^CVX||||||F|||20210202|||||||||||||||||| 832 OBX|2|DT|29768-9^VIS Publication Date^LN|1|20201201||||||F|||20210202|||||||||||||||||| 833 OBX|3|DT|29769-7^VIS Presentation Date^LN|1|20210202||||||F|||20210202|||||||||||||||||| 834 */ 835 836 RXA rxa = vxu.getORDER().getRXA(); 837 rxa.getRxa2_AdministrationSubIDCounter().setValue("1"); 838 rxa.getRxa2_AdministrationSubIDCounter() 839 .getExtraComponents() 840 .getComponent(0) 841 .getData() 842 .parse("http://acme.org/medadmins"); 843 rxa.getRxa3_DateTimeStartOfAdministration().getTs1_Time().setValue("20171209071055-0500"); 844 rxa.getRxa4_DateTimeEndOfAdministration().getTs1_Time().setValue("20171209071100-0500"); 845 rxa.getRxa5_AdministeredCode().getCe1_Identifier().setValue("208"); 846 rxa.getRxa5_AdministeredCode().getCe2_Text().setValue("COVID-19, MRNA, LNP-S, PF, 30 MCG/0.3 ML"); 847 rxa.getRxa5_AdministeredCode().getCe3_NameOfCodingSystem().setValue("http://acme.org/meds"); 848 rxa.getRxa6_AdministeredAmount().setValue("4"); 849 rxa.getRxa7_AdministeredUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 850 rxa.getRxa9_AdministrationNotes(0).getCe2_Text().setValue("This is a note"); 851 852 rxa.getRxa10_AdministeringProvider(0).getXcn1_IDNumber().setValue("825"); 853 rxa.getRxa10_AdministeringProvider(0) 854 .getXcn2_FamilyName() 855 .getFn1_Surname() 856 .setValue("Bouvier"); 857 rxa.getRxa10_AdministeringProvider(0).getXcn3_GivenName().setValue("Marge"); 858 rxa.getRxa10_AdministeringProvider(0) 859 .getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof() 860 .setValue("Q"); 861 rxa.getRxa10_AdministeringProvider(0) 862 .getXcn9_AssigningAuthority() 863 .getHd1_NamespaceID() 864 .setValue("http://acme.org/clinicians"); 865 866 rxa.getRxa12_AdministeredPerTimeUnit().setValue("Day"); 867 rxa.getRxa20_CompletionStatus().setValue("CP"); 868 869 populateRxr(vxu.getORDER().getRXR()); 870 871 return vxu; 872 } 873 874 public void populateAil(AIL theAil) throws HL7Exception { 875 876 theAil.getAil1_SetIDAIL().setValue("4321"); 877 theAil.getAil2_SegmentActionCode().setValue("U"); // [A]dd, [D]elete, [U]pdate, [X] no change 878 theAil.getAil3_LocationResourceID(0) 879 .getPl1_PointOfCare() 880 .setValue("locations^http://acme.org/location/321^DNS"); 881 theAil.getAil3_LocationResourceID(0).getPl2_Room().setValue("room^http://acme.org/location/room/321^DNS"); 882 theAil.getAil3_LocationResourceID(0).getPl3_Bed().setValue("bed^http://acme.org/location/room/321/bed/a^DNS"); 883 // AIL-3.PL-10.EI-1,EI-2 are responsible for a location's first identifier 884 theAil.getAil3_LocationResourceID(0) 885 .getPl10_ComprehensiveLocationIdentifier() 886 .getEi1_EntityIdentifier() 887 .setValue("6789"); 888 theAil.getAil3_LocationResourceID(0) 889 .getPl10_ComprehensiveLocationIdentifier() 890 .getEi2_NamespaceID() 891 .setValue("http://acme.org/locaton"); 892 theAil.getAil3_LocationResourceID(0) 893 .getPl11_AssigningAuthorityForLocation() 894 .getHd1_NamespaceID() 895 .setValue("http://acme.org"); 896 897 theAil.getAil4_LocationTypeAIL().getCe1_Identifier().setValue("C"); 898 899 theAil.getAil6_StartDateTime().getTs1_Time().setValue("202104121335-0500"); 900 901 theAil.getAil9_Duration().setValue("30"); 902 theAil.getAil10_DurationUnits().getCe1_Identifier().setValue("minutes"); 903 theAil.getAil10_DurationUnits().getCe2_Text().setValue("Minutes"); 904 } 905 906 public void populateAip(AIP theAip) throws HL7Exception { 907 908 theAip.getAip1_SetIDAIP().setValue("6543"); 909 theAip.getAip2_SegmentActionCode().setValue("U"); // [A]dd, [D]elete, [U]pdate, [X] no change 910 theAip.getAip3_PersonnelResourceID(0).getXcn1_IDNumber().setValue("5432"); 911 theAip.getAip3_PersonnelResourceID(0) 912 .getXcn2_FamilyName() 913 .getFn1_Surname() 914 .setValue("Smith"); 915 theAip.getAip3_PersonnelResourceID(0).getXcn3_GivenName().setValue("Jane"); 916 theAip.getAip3_PersonnelResourceID(0) 917 .getXcn9_AssigningAuthority() 918 .getHd1_NamespaceID() 919 .setValue("http://acme.org"); 920 921 theAip.getAip4_ResourceType().getCe1_Identifier().setValue("PPRF"); 922 923 theAip.getAip6_StartDateTime().getTs1_Time().setValue("202104121335-0500"); 924 925 theAip.getAip9_Duration().setValue("30"); 926 theAip.getAip10_DurationUnits().getCe1_Identifier().setValue("minutes"); 927 theAip.getAip10_DurationUnits().getCe2_Text().setValue("Minutes"); 928 929 theAip.getAip12_FillerStatusCode().getCe1_Identifier().setValue("Booked"); 930 } 931 932 public void populateDg1(DG1 theDg1) throws DataTypeException { 933 theDg1.getDg13_DiagnosisCodeDG1().getCe1_Identifier().setValue("193462001"); 934 theDg1.getDg13_DiagnosisCodeDG1().getCe2_Text().setValue("Insomnia"); 935 theDg1.getDg13_DiagnosisCodeDG1().getCe3_NameOfCodingSystem().setValue("http://snomed.info/sct"); 936 } 937 938 public DG1 populateDg1(DG1 theDg1, boolean includeDiagnosisTypeAndPriority) throws HL7Exception { 939 theDg1.getDg13_DiagnosisCodeDG1().getCe1_Identifier().setValue("193462001"); 940 theDg1.getDg13_DiagnosisCodeDG1().getCe2_Text().setValue("Insomnia"); 941 theDg1.getDg13_DiagnosisCodeDG1().getCe3_NameOfCodingSystem().setValue("http://snomed.info/sct"); 942 943 theDg1.getDg15_DiagnosisDateTime().getTs1_Time().setValue("20010101070000-0400"); 944 945 if (includeDiagnosisTypeAndPriority) { 946 theDg1.getDg16_DiagnosisType().setValue("F"); 947 theDg1.getDg115_DiagnosisPriority().setValue("1"); 948 } 949 950 XCN dg116 = theDg1.insertDg116_DiagnosingClinician(0); 951 populateXcn(dg116); 952 953 theDg1.getDg120_DiagnosisIdentifier().getEi1_EntityIdentifier().setValue("0000000042"); 954 theDg1.getDg120_DiagnosisIdentifier().getEi2_NamespaceID().setValue("http://acme.org/diagnosis-identifiers"); 955 956 return theDg1; 957 } 958 959 public void populateGt1(GT1 theGt1) throws HL7Exception { 960 theGt1.getGt12_GuarantorNumber(0).getCx1_IDNumber().setValue("23323"); 961 theGt1.getGt12_GuarantorNumber(0) 962 .getCx4_AssigningAuthority() 963 .getHd1_NamespaceID() 964 .setValue("http://acme.org/guarantors"); 965 theGt1.getGt12_GuarantorNumber(1).getCx1_IDNumber().setValue("32332"); 966 theGt1.getGt12_GuarantorNumber(1) 967 .getCx4_AssigningAuthority() 968 .getHd1_NamespaceID() 969 .setValue("http://acme.org/guarantors"); 970 XPN gt13 = theGt1.insertGt13_GuarantorName(0); 971 gt13.getXpn1_FamilyName().getFn1_Surname().setValue("Smith"); 972 gt13.getXpn2_GivenName().setValue("Fannie"); 973 gt13.getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().setValue("Foo"); 974 gt13.getXpn4_SuffixEgJRorIII().setValue("Jr"); 975 gt13.getXpn7_NameTypeCode().setValue("L"); 976 XAD gt15 = theGt1.insertGt15_GuarantorAddress(0); 977 gt15.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("313 Fleet Street"); 978 gt15.getXad3_City().setValue("Cheektowaga"); 979 gt15.getXad4_StateOrProvince().setValue("NY"); 980 gt15.getXad5_ZipOrPostalCode().setValue("28366"); 981 gt15.getXad6_Country().setValue("USA"); 982 gt15.getXad7_AddressType().setValue("W"); 983 XTN gt16 = theGt1.insertGt16_GuarantorPhNumHome(0); 984 gt16.getXtn1_TelephoneNumber().setValue("1(333)555-1234"); 985 gt16.getXtn2_TelecommunicationUseCode().setValue("PRN"); 986 gt16.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 987 theGt1.getGt18_GuarantorDateTimeOfBirth().getTs1_Time().setValue("19000102"); 988 theGt1.getGt19_GuarantorAdministrativeSex().setValue("M"); 989 theGt1.getGt111_GuarantorRelationship().getCe1_Identifier().setValue("MTH"); 990 theGt1.getGt111_GuarantorRelationship().getCe2_Text().setValue("mother"); 991 theGt1.getGt111_GuarantorRelationship() 992 .getCe3_NameOfCodingSystem() 993 .setValue(CodeSystemEnum.ROLE_CODE.getCodeSystemUri(ourContext)); 994 } 995 996 public void populateIam(IAM theIam) throws HL7Exception { 997 theIam.getIam2_AllergenTypeCode().getCe1_Identifier().setValue("DA"); 998 theIam.getIam2_AllergenTypeCode().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0127); 999 theIam.getIam3_AllergenCodeMnemonicDescription().getCe1_Identifier().setValue("256259004"); 1000 theIam.getIam3_AllergenCodeMnemonicDescription().getCe2_Text().setValue("Pollen (Substance)"); 1001 theIam.getIam3_AllergenCodeMnemonicDescription() 1002 .getCe3_NameOfCodingSystem() 1003 .setValue(PublicApiConstants.CODE_SYSTEM_SNOMED); 1004 theIam.getIam4_AllergySeverityCode().getCe1_Identifier().setValue("SV"); 1005 theIam.getIam4_AllergySeverityCode().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0128); 1006 theIam.getIam5_AllergyReactionCode(0).setValue("Wheezing"); 1007 theIam.getIam5_AllergyReactionCode(1).setValue("Puking Guts Out"); 1008 theIam.getIam7_AllergyUniqueIdentifier().getEi1_EntityIdentifier().setValue("88344"); 1009 theIam.getIam7_AllergyUniqueIdentifier().getEi2_NamespaceID().setValue("http://acme.org/allergies"); 1010 theIam.getIam11_OnsetDate().parse("20170203"); 1011 theIam.getIam13_ReportedDateTime().parse("20170204"); 1012 theIam.getIam17_AllergyClinicalStatusCode().getCe1_Identifier().setValue("C"); 1013 theIam.getIam17_AllergyClinicalStatusCode().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0438); 1014 } 1015 1016 public void populateAl1(AL1 theIam) throws HL7Exception { 1017 theIam.getAl12_AllergenTypeCode().getCe1_Identifier().setValue("DA"); 1018 theIam.getAl12_AllergenTypeCode().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0127); 1019 theIam.getAl13_AllergenCodeMnemonicDescription().getCe1_Identifier().setValue("256259004"); 1020 theIam.getAl13_AllergenCodeMnemonicDescription().getCe2_Text().setValue("Pollen (Substance)"); 1021 theIam.getAl13_AllergenCodeMnemonicDescription() 1022 .getCe3_NameOfCodingSystem() 1023 .setValue(PublicApiConstants.CODE_SYSTEM_SNOMED); 1024 theIam.getAl14_AllergySeverityCode().getCe1_Identifier().setValue("SV"); 1025 theIam.getAl14_AllergySeverityCode().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0128); 1026 theIam.getAl15_AllergyReactionCode(0).setValue("Wheezing"); 1027 theIam.getAl15_AllergyReactionCode(1).setValue("Puking Guts Out"); 1028 theIam.getAl16_IdentificationDate().setValue("20001231"); 1029 } 1030 1031 public void populateIn1(IN1 theIn1) throws DataTypeException { 1032 theIn1.getIn12_InsurancePlanID().getCe3_NameOfCodingSystem().setValue("http://acme.org/insurancePlanIds"); 1033 theIn1.getIn12_InsurancePlanID().getCe1_Identifier().setValue("449988"); 1034 theIn1.getIn13_InsuranceCompanyID(0).getCx1_IDNumber().setValue("443322"); 1035 theIn1.getIn13_InsuranceCompanyID(0) 1036 .getCx4_AssigningAuthority() 1037 .getHd1_NamespaceID() 1038 .setValue("http://acme.org/insurerIds"); 1039 theIn1.getIn14_InsuranceCompanyName(0).getXon1_OrganizationName().setValue("InsurerCo"); 1040 theIn1.getIn15_InsuranceCompanyAddress(0) 1041 .getXad1_StreetAddress() 1042 .getSad1_StreetOrMailingAddress() 1043 .setValue("342 Evergreen Terrace"); 1044 theIn1.getIn15_InsuranceCompanyAddress(0).getXad2_OtherDesignation().setValue("2nd Floor"); 1045 theIn1.getIn15_InsuranceCompanyAddress(0).getXad3_City().setValue("Springfield"); 1046 theIn1.getIn15_InsuranceCompanyAddress(0).getXad4_StateOrProvince().setValue("NI"); 1047 theIn1.getIn15_InsuranceCompanyAddress(0).getXad5_ZipOrPostalCode().setValue("12345"); 1048 theIn1.getIn15_InsuranceCompanyAddress(0).getXad6_Country().setValue("USA"); 1049 theIn1.getIn15_InsuranceCompanyAddress(0).getXad7_AddressType().setValue("W"); 1050 theIn1.getIn116_NameOfInsured(0).getXpn1_FamilyName().getFn1_Surname().setValue("Smith"); 1051 theIn1.getIn116_NameOfInsured(0).getXpn2_GivenName().setValue("John"); 1052 theIn1.getIn116_NameOfInsured(0) 1053 .getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof() 1054 .setValue("Q"); 1055 theIn1.getIn116_NameOfInsured(0).getXpn4_SuffixEgJRorIII().setValue("Jr"); 1056 theIn1.getIn116_NameOfInsured(0).getXpn7_NameTypeCode().setValue("L"); 1057 } 1058 1059 public void populateIn1Difference(IN1 theIn1, String identifier) throws DataTypeException { 1060 theIn1.getIn12_InsurancePlanID().getCe3_NameOfCodingSystem().setValue("http://acme.org/insurancePlanIds"); 1061 theIn1.getIn12_InsurancePlanID().getCe1_Identifier().setValue("449988" + identifier); 1062 theIn1.getIn13_InsuranceCompanyID(0).getCx1_IDNumber().setValue("443322" + identifier); 1063 theIn1.getIn13_InsuranceCompanyID(0) 1064 .getCx4_AssigningAuthority() 1065 .getHd1_NamespaceID() 1066 .setValue("http://acme.org/insurerIds"); 1067 theIn1.getIn14_InsuranceCompanyName(0).getXon1_OrganizationName().setValue("InsurerCo" + identifier); 1068 theIn1.getIn15_InsuranceCompanyAddress(0) 1069 .getXad1_StreetAddress() 1070 .getSad1_StreetOrMailingAddress() 1071 .setValue("342 Evergreen Terrace"); 1072 theIn1.getIn15_InsuranceCompanyAddress(0).getXad2_OtherDesignation().setValue("2nd Floor"); 1073 theIn1.getIn15_InsuranceCompanyAddress(0).getXad3_City().setValue("Springfield"); 1074 theIn1.getIn15_InsuranceCompanyAddress(0).getXad4_StateOrProvince().setValue("NI"); 1075 theIn1.getIn15_InsuranceCompanyAddress(0).getXad5_ZipOrPostalCode().setValue("12345"); 1076 theIn1.getIn15_InsuranceCompanyAddress(0).getXad6_Country().setValue("USA"); 1077 theIn1.getIn15_InsuranceCompanyAddress(0).getXad7_AddressType().setValue("W"); 1078 theIn1.getIn116_NameOfInsured(0).getXpn1_FamilyName().getFn1_Surname().setValue("Smith"); 1079 theIn1.getIn116_NameOfInsured(0).getXpn2_GivenName().setValue("John"); 1080 theIn1.getIn116_NameOfInsured(0) 1081 .getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof() 1082 .setValue("Q"); 1083 theIn1.getIn116_NameOfInsured(0).getXpn4_SuffixEgJRorIII().setValue("Jr"); 1084 theIn1.getIn116_NameOfInsured(0).getXpn7_NameTypeCode().setValue("L"); 1085 } 1086 1087 public void populateIn2(IN2 theIn2) throws HL7Exception { 1088 theIn2.getIn214_MilitaryService().setValue("A"); 1089 theIn2.getIn214_MilitaryService() 1090 .getExtraComponents() 1091 .getComponent(0) 1092 .getData() 1093 .parse("U.S. ARMY"); 1094 theIn2.getIn214_MilitaryService() 1095 .getExtraComponents() 1096 .getComponent(1) 1097 .getData() 1098 .parse("urn:test:source:militarybranch"); 1099 theIn2.getIn214_MilitaryService() 1100 .getExtraComponents() 1101 .getComponent(2) 1102 .getData() 1103 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information"); 1104 theIn2.getIn214_MilitaryService() 1105 .getExtraComponents() 1106 .getComponent(3) 1107 .getData() 1108 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information/military-branch"); 1109 1110 theIn2.getIn215_MilitaryRankGrade().setValue("MG"); 1111 theIn2.getIn215_MilitaryRankGrade() 1112 .getExtraComponents() 1113 .getComponent(0) 1114 .getData() 1115 .parse("O8 MAJ GENERAL"); 1116 theIn2.getIn215_MilitaryRankGrade() 1117 .getExtraComponents() 1118 .getComponent(1) 1119 .getData() 1120 .parse("urn:test:source:militaryrank"); 1121 theIn2.getIn215_MilitaryRankGrade() 1122 .getExtraComponents() 1123 .getComponent(2) 1124 .getData() 1125 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information"); 1126 theIn2.getIn215_MilitaryRankGrade() 1127 .getExtraComponents() 1128 .getComponent(3) 1129 .getData() 1130 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information/military-rank"); 1131 1132 theIn2.getIn216_MilitaryStatus().setValue("R"); 1133 theIn2.getIn216_MilitaryStatus() 1134 .getExtraComponents() 1135 .getComponent(0) 1136 .getData() 1137 .parse("RETIRED"); 1138 theIn2.getIn216_MilitaryStatus() 1139 .getExtraComponents() 1140 .getComponent(1) 1141 .getData() 1142 .parse("urn:test:source:militarystatus"); 1143 theIn2.getIn216_MilitaryStatus() 1144 .getExtraComponents() 1145 .getComponent(2) 1146 .getData() 1147 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information"); 1148 theIn2.getIn216_MilitaryStatus() 1149 .getExtraComponents() 1150 .getComponent(3) 1151 .getData() 1152 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information/military-status"); 1153 } 1154 1155 public void populateMsh(MSH theMsh, String messageType) throws HL7Exception { 1156 theMsh.getMsh1_FieldSeparator().setValue("|"); 1157 theMsh.getMsh2_EncodingCharacters().setValue("^~\\&"); 1158 theMsh.getMsh3_SendingApplication().getHd1_NamespaceID().setValue("http://acme.org/application"); 1159 theMsh.getMsh3_SendingApplication().getHd2_UniversalID().setValue("ACME Application"); 1160 theMsh.getMsh4_SendingFacility().getHd1_NamespaceID().setValue("http://acme.org/facility"); 1161 theMsh.getMsh4_SendingFacility().getHd2_UniversalID().setValue("Acme Facility"); 1162 theMsh.getMsh9_MessageType().parse(messageType); 1163 theMsh.getMsh10_MessageControlID().setValue("A001"); 1164 theMsh.getMsh11_ProcessingID().parse("T"); 1165 theMsh.getMsh12_VersionID().parse("2.5"); 1166 } 1167 1168 public void populateNk1Employer(NK1 theNk1) throws HL7Exception { 1169 theNk1.getNk11_SetIDNK1().setValue("2"); 1170 1171 XPN nk12 = theNk1.insertNk12_NKName(0); 1172 nk12.getXpn1_FamilyName().getFn1_Surname().setValue("Burns"); 1173 nk12.getXpn2_GivenName().setValue("Charles"); 1174 nk12.getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().setValue("Montgomery"); 1175 1176 CE nk13 = theNk1.getNk13_Relationship(); 1177 nk13.getCe1_Identifier().setValue("ECON"); 1178 nk13.getCe2_Text().setValue("Employer"); 1179 nk13.getCe3_NameOfCodingSystem().setValue(CodeSystemEnum.ROLE_CODE.getCodeSystemUri(ourContext)); 1180 1181 XAD nk14 = theNk1.insertNk14_Address(0); 1182 nk14.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("999 Mammon Avenue"); 1183 nk14.getXad3_City().setValue("Springfield"); 1184 nk14.getXad4_StateOrProvince().setValue("MO"); 1185 nk14.getXad5_ZipOrPostalCode().setValue("91656"); 1186 nk14.getXad6_Country().setValue("USA"); 1187 nk14.getXad7_AddressType().setValue("W"); 1188 1189 XTN nk15 = theNk1.insertNk16_BusinessPhoneNumber(0); 1190 nk15.getXtn1_TelephoneNumber().setValue("(636)555-5678"); 1191 nk15.getXtn2_TelecommunicationUseCode().setValue("WPN"); 1192 nk15.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 1193 nk15.getXtn6_AreaCityCode().setValue("636"); 1194 nk15.getXtn7_LocalNumber().setValue("5555678"); 1195 1196 CE nk17 = theNk1.getNk17_ContactRole(); 1197 nk17.getCe1_Identifier().setValue("E"); 1198 nk17.getCe2_Text().setValue("Employer"); 1199 nk17.getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0131_R4); 1200 1201 theNk1.getNk115_AdministrativeSex().setValue("M"); 1202 1203 XON nk113 = theNk1.insertOrganizationNameNK1(0); 1204 nk113.getXon1_OrganizationName().setValue("Springfield Nuclear Power Plant"); 1205 1206 theNk1.getNk18_StartDate().setValue("201506"); 1207 1208 CX nk133 = theNk1.insertNk133_NextOfKinAssociatedPartySIdentifiers(0); 1209 nk133.getCx1_IDNumber().setValue("0123456789"); 1210 nk133.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue("http://acme.org/organization"); 1211 } 1212 1213 public void populateNk1NextOfKin(NK1 theNk1) throws HL7Exception { 1214 theNk1.getNk11_SetIDNK1().setValue("1"); 1215 1216 XPN nk12 = theNk1.insertNk12_NKName(0); 1217 nk12.getXpn1_FamilyName().getFn1_Surname().setValue("Simpson"); 1218 nk12.getXpn2_GivenName().setValue("Marjorie"); 1219 nk12.getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().setValue("Marge"); 1220 1221 CE nk13 = theNk1.getNk13_Relationship(); 1222 nk13.getCe1_Identifier().setValue("MTH"); 1223 nk13.getCe2_Text().setValue("Mother"); 1224 nk13.getCe3_NameOfCodingSystem().setValue(CodeSystemEnum.ROLE_CODE.getCodeSystemUri(ourContext)); 1225 1226 XAD nk14 = theNk1.insertNk14_Address(0); 1227 nk14.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("742 Evergreen Terrace"); 1228 nk14.getXad3_City().setValue("Springfield"); 1229 nk14.getXad4_StateOrProvince().setValue("MO"); 1230 nk14.getXad5_ZipOrPostalCode().setValue("65619"); 1231 nk14.getXad6_Country().setValue("USA"); 1232 nk14.getXad7_AddressType().setValue("H"); 1233 1234 XTN nk15 = theNk1.insertNk15_PhoneNumber(0); 1235 nk15.getXtn1_TelephoneNumber().setValue("(636)555-1234"); 1236 nk15.getXtn2_TelecommunicationUseCode().setValue("PRN"); 1237 nk15.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 1238 nk15.getXtn6_AreaCityCode().setValue("636"); 1239 nk15.getXtn7_LocalNumber().setValue("5551234"); 1240 1241 CE nk17 = theNk1.getNk17_ContactRole(); 1242 nk17.getCe1_Identifier().setValue("N"); 1243 nk17.getCe2_Text().setValue("Next-of-Kin"); 1244 nk17.getCe3_NameOfCodingSystem().setValue(PublicApiConstants.TABLE_0131_R4); 1245 1246 theNk1.getNk18_StartDate().setValue("2011"); 1247 theNk1.getNk19_EndDate().setValue("20120102"); 1248 1249 theNk1.getNk110_NextOfKinAssociatedPartiesJobTitle().setValue("Clown"); 1250 theNk1.getNk114_MaritalStatus().getCe1_Identifier().setValue("I"); 1251 1252 theNk1.getNk115_AdministrativeSex().setValue("F"); 1253 theNk1.getNk116_DateTimeOfBirth().parse("20210101121212-0000"); 1254 theNk1.getNk129_ContactReason(0).parse("EMER^Emergency^http://contact-reasons"); 1255 theNk1.getNk130_ContactPersonSName(0) 1256 .getXpn1_FamilyName() 1257 .getFn1_Surname() 1258 .setValue("Alt Family Name"); 1259 1260 theNk1.getNk113_OrganizationNameNK1(0).getXon1_OrganizationName().setValue("Org Name"); 1261 theNk1.getNk133_NextOfKinAssociatedPartySIdentifiers(0) 1262 .getCx1_IDNumber() 1263 .setValue("12345"); 1264 theNk1.getNk133_NextOfKinAssociatedPartySIdentifiers(0) 1265 .getCx4_AssigningAuthority() 1266 .getHd1_NamespaceID() 1267 .setValue("http://ids"); 1268 } 1269 1270 public void populateObxAssessmentHeight(Message theMessage, OBX theObx) throws DataTypeException { 1271 theObx.getObx2_ValueType().setValue("NM"); 1272 theObx.getObx3_ObservationIdentifier().getCe1_Identifier().setValue(PublicApiConstants.CODE_LOINC_BODY_HEIGHT); 1273 theObx.getObx3_ObservationIdentifier().getCe2_Text().setValue(PublicApiConstants.CODE_LOINC_BODY_HEIGHT_TEXT); 1274 theObx.getObx3_ObservationIdentifier().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.CODE_SYSTEM_LOINC); 1275 NM obxHtNm = new NM(theMessage); 1276 obxHtNm.setValue("51"); 1277 theObx.getObx5_ObservationValue(0).setData(obxHtNm); 1278 theObx.getObx6_Units().getCe1_Identifier().setValue("cm"); 1279 theObx.getObx6_Units().getCe2_Text().setValue("cm"); 1280 theObx.getObx6_Units().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.CODE_SYSTEM_UCUM); 1281 theObx.getObx11_ObservationResultStatus().setValue("F"); 1282 theObx.getObx14_DateTimeOfTheObservation().getTs1_Time().setValue("201109031113-0400"); 1283 } 1284 1285 public void populateObxAssessmentWeight(Message a01, OBX theObx) throws DataTypeException { 1286 theObx.getObx2_ValueType().setValue("NM"); 1287 theObx.getObx3_ObservationIdentifier().getCe1_Identifier().setValue(PublicApiConstants.CODE_LOINC_BODY_WEIGHT); 1288 theObx.getObx3_ObservationIdentifier().getCe2_Text().setValue(PublicApiConstants.CODE_LOINC_BODY_WEIGHT_TEXT); 1289 theObx.getObx3_ObservationIdentifier().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.CODE_SYSTEM_LOINC); 1290 NM obxWtNm = new NM(a01); 1291 obxWtNm.setValue("123.4"); 1292 theObx.getObx5_ObservationValue(0).setData(obxWtNm); 1293 theObx.getObx6_Units().getCe1_Identifier().setValue("kg"); 1294 theObx.getObx6_Units().getCe2_Text().setValue("kg"); 1295 theObx.getObx6_Units().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.CODE_SYSTEM_UCUM); 1296 theObx.getObx11_ObservationResultStatus().setValue("F"); 1297 theObx.getObx14_DateTimeOfTheObservation().getTs1_Time().setValue("201109031113-0400"); 1298 } 1299 1300 public void populateOrcForMedication( 1301 ORC theOrc, String theOrderControl, boolean thePopulateOrc2, boolean thePopulateOrc3) throws HL7Exception { 1302 theOrc.getOrc1_OrderControl().setValue(theOrderControl); 1303 if (thePopulateOrc2) { 1304 theOrc.getOrc2_PlacerOrderNumber().getEi1_EntityIdentifier().setValue("0001"); 1305 theOrc.getOrc2_PlacerOrderNumber().getEi2_NamespaceID().setValue("http://acme.org/medorders"); 1306 } 1307 if (thePopulateOrc3) { 1308 theOrc.getOrc3_FillerOrderNumber().getEi1_EntityIdentifier().setValue("0002"); 1309 theOrc.getOrc3_FillerOrderNumber().getEi2_NamespaceID().setValue("http://acme.org/medorders"); 1310 } 1311 1312 TQ orc7 = theOrc.insertOrc7_QuantityTiming(0); 1313 orc7.getTq4_StartDateTime().getTs1_Time().setValue("201701021110-0500"); 1314 1315 theOrc.getOrc9_DateTimeOfTransaction().getTs1_Time().setValue("201701021110-0500"); 1316 1317 XCN orc12 = theOrc.insertOrc12_OrderingProvider(0); 1318 populateXcn(orc12); 1319 } 1320 1321 public void populatePid(PID thePid) throws HL7Exception { 1322 populatePid(thePid, true); 1323 } 1324 1325 public void populatePid(PID thePid, boolean theValid) throws HL7Exception { 1326 CX pid3 = thePid.insertPid3_PatientIdentifierList(0); 1327 pid3.getCx1_IDNumber().setValue("7000135"); 1328 1329 // If we're creating an invalid message, we'll skip all the mandatory bits of PID-3, since this is a 1330 // pretty common screwup 1331 if (theValid) { 1332 pid3.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue("http://acme.org/mrns"); 1333 pid3.getCx5_IdentifierTypeCode().setValue("MR"); 1334 pid3 = thePid.insertPid3_PatientIdentifierList(1); 1335 pid3.getCx1_IDNumber().setValue("01238638267"); 1336 pid3.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue("http://acme.org/secondaryIds"); 1337 pid3.getCx5_IdentifierTypeCode().setValue("SB"); 1338 } 1339 XPN pid5 = thePid.insertPid5_PatientName(0); 1340 pid5.getXpn1_FamilyName().getFn1_Surname().setValue("Smith"); 1341 pid5.getXpn2_GivenName().setValue("John"); 1342 pid5.getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().setValue("Q"); 1343 pid5.getXpn4_SuffixEgJRorIII().setValue("Jr"); 1344 pid5.getXpn7_NameTypeCode().setValue("L"); 1345 1346 XPN pid6 = thePid.insertPid6_MotherSMaidenName(0); 1347 pid6.getXpn1_FamilyName().getFn1_Surname().setValue("Smythe"); 1348 pid6.getXpn2_GivenName().setValue("Jane"); 1349 pid6.getXpn3_SecondAndFurtherGivenNamesOrInitialsThereof().setValue("K"); 1350 pid6.getXpn4_SuffixEgJRorIII().setValue("Sr"); 1351 pid6.getXpn7_NameTypeCode().setValue("D"); 1352 1353 thePid.getPid7_DateTimeOfBirth().getTs1_Time().setValue("19650322"); 1354 1355 thePid.getPid8_AdministrativeSex().setValue("M"); 1356 1357 CE pid10 = thePid.getPid10_Race(0); 1358 pid10.getCe1_Identifier().setValue("2028-9"); 1359 pid10.getCe2_Text().setValue("Asian"); 1360 pid10.getCe3_NameOfCodingSystem().setValue("urn:oid:2.16.840.1.113883.6.238"); 1361 pid10.getExtraComponents() 1362 .getComponent(0) 1363 .getData() 1364 .parse("http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"); 1365 pid10.getExtraComponents().getComponent(1).getData().parse("ombCategory"); 1366 1367 XAD pid11 = thePid.insertPid11_PatientAddress(0); 1368 pid11.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("342 Evergreen Terrace"); 1369 pid11.getXad2_OtherDesignation().setValue("2nd Floor"); 1370 pid11.getXad3_City().setValue("Springfield"); 1371 pid11.getXad4_StateOrProvince().setValue("NI"); 1372 pid11.getXad5_ZipOrPostalCode().setValue("12345"); 1373 pid11.getXad6_Country().setValue("USA"); 1374 pid11.getXad7_AddressType().setValue("H"); 1375 1376 XTN pid13 = thePid.insertPid13_PhoneNumberHome(0); 1377 pid13.getXtn1_TelephoneNumber().setValue("1(333)555-1234"); 1378 pid13.getXtn2_TelecommunicationUseCode().setValue("PRN"); 1379 pid13.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 1380 1381 thePid.getPid15_PrimaryLanguage().parse("EN^English^http://languages"); 1382 1383 CE pid16 = thePid.getPid16_MaritalStatus(); 1384 pid16.getCe1_Identifier().setValue("I"); 1385 1386 CE pid17 = thePid.getPid17_Religion(); 1387 pid17.getCe1_Identifier().setValue("AGNOSTIC"); 1388 pid17.getCe2_Text().setValue("Agnostic"); 1389 pid17.getCe3_NameOfCodingSystem().setValue("urn:test:source:religion"); 1390 pid17.getExtraComponents() 1391 .getComponent(0) 1392 .getData() 1393 .parse("http://hl7.org/fhir/StructureDefinition/patient-religion"); 1394 1395 CX pid18 = thePid.getPid18_PatientAccountNumber(); 1396 pid18.getCx1_IDNumber().setValue("123456789"); 1397 pid18.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue("http://acme.org/patientAccountNumbers"); 1398 pid18.getCx5_IdentifierTypeCode().setValue("AN"); 1399 1400 CE pid22 = thePid.getPid22_EthnicGroup(0); 1401 pid22.getCe1_Identifier().setValue("2135-2"); 1402 pid22.getCe2_Text().setValue("Hispanic or Latino"); 1403 pid22.getCe3_NameOfCodingSystem().setValue("urn:oid:2.16.840.1.113883.6.238"); 1404 pid22.getExtraComponents() 1405 .getComponent(0) 1406 .getData() 1407 .parse("http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"); 1408 pid22.getExtraComponents().getComponent(1).getData().parse("ombCategory"); 1409 1410 // Adding multiple PID-26 1411 CE pid26_1 = thePid.getPid26_Citizenship(0); 1412 pid26_1.getCe1_Identifier().setValue("1"); 1413 pid26_1.getCe2_Text().setValue("CA"); 1414 pid26_1.getCe3_NameOfCodingSystem().setValue("urn:test:source:citizenship"); 1415 CE pid26_2 = thePid.getPid26_Citizenship(1); 1416 pid26_2.getCe1_Identifier().setValue("2"); 1417 pid26_2.getCe2_Text().setValue("US"); 1418 pid26_2.getCe3_NameOfCodingSystem().setValue("urn:test:source:citizenship"); 1419 1420 CE pid27 = thePid.getPid27_VeteransMilitaryStatus(); 1421 pid27.getCe1_Identifier().setValue("N"); 1422 pid27.getCe2_Text().setValue("Not a Veteran"); 1423 pid27.getCe3_NameOfCodingSystem().setValue("urn:test:source:vetstatus"); 1424 pid27.getExtraComponents() 1425 .getComponent(0) 1426 .getData() 1427 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information"); 1428 pid27.getExtraComponents() 1429 .getComponent(1) 1430 .getData() 1431 .parse("http://acme.org/fhir/StructureDefinition/patient-military-information/vet-status"); 1432 1433 CE pid28 = thePid.getPid28_Nationality(); 1434 pid28.getCe1_Identifier().setValue("1"); 1435 pid28.getCe2_Text().setValue("Canadian"); 1436 pid28.getCe3_NameOfCodingSystem().setValue("urn:test:source:nationality"); 1437 1438 thePid.getPid30_PatientDeathIndicator().setValue("N"); 1439 } 1440 1441 private void populateMrg(MRG theMrg) throws HL7Exception { 1442 CX mrg1 = theMrg.insertPriorPatientIdentifierList(0); 1443 mrg1.getCx1_IDNumber().setValue("7000135"); 1444 mrg1.getCx4_AssigningAuthority().getHd1_NamespaceID().setValue("http://acme.org/mrns"); 1445 mrg1.getCx5_IdentifierTypeCode().setValue("MR"); 1446 } 1447 1448 public void populatePr1First(PR1 thePr1) throws DataTypeException { 1449 thePr1.getPr11_SetIDPR1().setValue("1"); 1450 thePr1.getPr13_ProcedureCode().getCe1_Identifier().setValue("2W53XYZ"); 1451 thePr1.getPr13_ProcedureCode().getCe2_Text().setValue("Removal of Other Device on Abdominal Wall"); 1452 thePr1.getPr13_ProcedureCode() 1453 .getCe3_NameOfCodingSystem() 1454 .setValue(CodeSystemEnum.PCS.getCodeSystemUri(ourContext)); 1455 thePr1.getPr14_ProcedureDescription().setValue("Face Transplant"); 1456 thePr1.getPr15_ProcedureDateTime().getTs1_Time().setValue("20010101070000-0400"); 1457 thePr1.getPr16_ProcedureFunctionalType().setValue("D"); 1458 thePr1.getPr119_ProcedureIdentifier().getEi1_EntityIdentifier().setValue("0000000042"); 1459 thePr1.getPr119_ProcedureIdentifier().getEi2_NamespaceID().setValue("http://acme.org/procedure-identifiers"); 1460 } 1461 1462 public void populatePr1Second(PR1 thePr1) throws DataTypeException { 1463 thePr1.getPr11_SetIDPR1().setValue("2"); 1464 thePr1.getPr13_ProcedureCode().getCe1_Identifier().setValue("02HV33Z"); 1465 thePr1.getPr13_ProcedureCode() 1466 .getCe2_Text() 1467 .setValue("Insertion of Infusion Device into Superior Vena Cava, Percutaneous Approach"); 1468 thePr1.getPr13_ProcedureCode() 1469 .getCe3_NameOfCodingSystem() 1470 .setValue(CodeSystemEnum.PCS.getCodeSystemUri(ourContext)); 1471 thePr1.getPr15_ProcedureDateTime().getTs1_Time().setValue("20010101070000-0400"); 1472 thePr1.getPr119_ProcedureIdentifier().getEi1_EntityIdentifier().setValue("0000000042"); 1473 thePr1.getPr119_ProcedureIdentifier().getEi2_NamespaceID().setValue("http://acme.org/procedure-identifiers"); 1474 } 1475 1476 public void populatePv1(PV1 thePv1) throws HL7Exception { 1477 thePv1.getPv12_PatientClass().setValue("I"); 1478 thePv1.getPv13_AssignedPatientLocation().getPl1_PointOfCare().setValue("Acme Hospital"); 1479 thePv1.getPv13_AssignedPatientLocation().getPl2_Room().setValue("3rd Floor Room 124"); 1480 thePv1.getPv13_AssignedPatientLocation().getPl3_Bed().setValue("6"); 1481 thePv1.getPv13_AssignedPatientLocation() 1482 .getPl4_Facility() 1483 .getHd1_NamespaceID() 1484 .setValue("Acme Facility"); 1485 thePv1.getPv13_AssignedPatientLocation().getPl9_LocationDescription().setValue("The Acme Hospital"); 1486 thePv1.getPv13_AssignedPatientLocation() 1487 .getPl10_ComprehensiveLocationIdentifier() 1488 .getEi1_EntityIdentifier() 1489 .setValue("Acme H"); 1490 thePv1.getPv13_AssignedPatientLocation() 1491 .getPl10_ComprehensiveLocationIdentifier() 1492 .getEi2_NamespaceID() 1493 .setValue("http://acme.org/wards"); 1494 thePv1.getPv13_AssignedPatientLocation() 1495 .getExtraComponents() 1496 .getComponent(0) 1497 .getData() 1498 .parse("http://acme.org/facility"); 1499 thePv1.getPv13_AssignedPatientLocation() 1500 .getExtraComponents() 1501 .getComponent(1) 1502 .getData() 1503 .parse("Room 124, 3rd Floor"); 1504 thePv1.getPv13_AssignedPatientLocation() 1505 .getExtraComponents() 1506 .getComponent(2) 1507 .getData() 1508 .parse("124-3"); 1509 thePv1.getPv13_AssignedPatientLocation() 1510 .getExtraComponents() 1511 .getComponent(3) 1512 .getData() 1513 .parse("http://acme.org/rooms"); 1514 thePv1.getPv13_AssignedPatientLocation() 1515 .getExtraComponents() 1516 .getComponent(4) 1517 .getData() 1518 .parse("Bed 6"); 1519 thePv1.getPv13_AssignedPatientLocation() 1520 .getExtraComponents() 1521 .getComponent(5) 1522 .getData() 1523 .parse("B 6"); 1524 thePv1.getPv13_AssignedPatientLocation() 1525 .getExtraComponents() 1526 .getComponent(6) 1527 .getData() 1528 .parse("http://acme.org/beds"); 1529 thePv1.getPv14_AdmissionType().setValue("E"); 1530 thePv1.getPv115_AmbulatoryStatus(0).setValue("A1"); 1531 1532 populateXcn(thePv1.getPv17_AttendingDoctor(0)); 1533 thePv1.getPv110_HospitalService().setValue("1"); 1534 addExtraComponent(thePv1.getPv110_HospitalService(), 0, "Adoption/Permanent Care Info/Support"); 1535 addExtraComponent( 1536 thePv1.getPv110_HospitalService(), 1, CodeSystemEnum.SERVICE_TYPE.getCodeSystemUri(ourContext)); 1537 1538 thePv1.getPv114_AdmitSource().setValue("emd"); 1539 thePv1.getPv114_AdmitSource() 1540 .getExtraComponents() 1541 .getComponent(0) 1542 .getData() 1543 .parse("From accident/emergency department"); 1544 thePv1.getPv114_AdmitSource() 1545 .getExtraComponents() 1546 .getComponent(1) 1547 .getData() 1548 .parse(CodeSystemEnum.ADMIT_SOURCE.getCodeSystemUri(ourContext)); 1549 thePv1.getPv110_HospitalService().setValue("1"); 1550 thePv1.getPv118_PatientType().setValue("QQ"); 1551 thePv1.getPv119_VisitNumber().getCx1_IDNumber().setValue("4736455"); 1552 thePv1.getPv119_VisitNumber() 1553 .getCx4_AssigningAuthority() 1554 .getHd1_NamespaceID() 1555 .setValue("http://acme.org/visitNumbers"); 1556 thePv1.getPv119_VisitNumber().getCx5_IdentifierTypeCode().setValue("VN"); 1557 thePv1.getPv120_FinancialClass(0).getFc1_FinancialClassCode().setValue("FC1"); 1558 thePv1.getPv120_FinancialClass(0).getFc2_EffectiveDate().getTs1_Time().setValue("20210202121212-0000"); 1559 thePv1.getPv124_ContractCode(0).setValue("CC1"); 1560 thePv1.getPv136_DischargeDisposition().setValue("home"); 1561 thePv1.getPv136_DischargeDisposition() 1562 .getExtraComponents() 1563 .getComponent(0) 1564 .getData() 1565 .parse("Home"); 1566 thePv1.getPv136_DischargeDisposition() 1567 .getExtraComponents() 1568 .getComponent(1) 1569 .getData() 1570 .parse(CodeSystemEnum.DISCHARGE_DISPOSITION.getCodeSystemUri(ourContext)); 1571 thePv1.getPv139_ServicingFacility().setValue("Acme Facility"); 1572 thePv1.getPv139_ServicingFacility() 1573 .getExtraComponents() 1574 .getComponent(0) 1575 .getData() 1576 .parse("http://acme.org/facility"); 1577 thePv1.getPv141_AccountStatus().setValue("active"); 1578 thePv1.getPv144_AdmitDateTime().getTime().setValue("20160122094430-0400"); 1579 thePv1.insertPv145_DischargeDateTime(0).getTime().setValue("20160122094431-0400"); 1580 } 1581 1582 public void populatePv2(PV2 thePv2) throws HL7Exception { 1583 thePv2.getPv22_AccommodationCode().getCe1_Identifier().setValue("wheel"); 1584 thePv2.getPv22_AccommodationCode().getCe2_Text().setValue("Wheelchair"); 1585 thePv2.getPv22_AccommodationCode() 1586 .getCe3_NameOfCodingSystem() 1587 .setValue("http://terminology.hl7.org/CodeSystem/encounter-special-arrangements"); 1588 1589 thePv2.getPv23_AdmitReason().getCe1_Identifier().setValue("109006"); 1590 thePv2.getPv23_AdmitReason().getCe2_Text().setValue("Anxiety disorder of childhood OR adolescence"); 1591 thePv2.getPv23_AdmitReason().getCe3_NameOfCodingSystem().setValue("http://snomed.info/sct"); 1592 1593 thePv2.getPv24_TransferReason().getCe1_Identifier().setValue("TR"); 1594 thePv2.getPv24_TransferReason().getCe2_Text().setValue("Transfer Reasons"); 1595 thePv2.getPv24_TransferReason().getCe3_NameOfCodingSystem().setValue("http://transfer-reasons"); 1596 1597 thePv2.getPv28_ExpectedAdmitDateTime().getTs1_Time().setValue("20210203040506-0200"); 1598 thePv2.getPv29_ExpectedDischargeDateTime().getTs1_Time().setValue("20210605040302-0200"); 1599 1600 thePv2.getPv226_PreviousTreatmentDate().setValue("20190203"); 1601 thePv2.getPv227_ExpectedDischargeDisposition().parse("DD^Discharge Disposition^http://discharge-dispositions"); 1602 } 1603 1604 public void populateRolA(ROL theRol) throws HL7Exception { 1605 populateXcn(theRol.getRol4_RolePerson(0)); 1606 1607 XAD rol11 = theRol.insertRol11_OfficeHomeAddressBirthplace(0); 1608 rol11.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("123 Brewer Street"); 1609 rol11.getXad3_City().setValue("Buffalo"); 1610 rol11.getXad4_StateOrProvince().setValue("NY"); 1611 rol11.getXad5_ZipOrPostalCode().setValue("98765"); 1612 rol11.getXad6_Country().setValue("USA"); 1613 rol11.getXad7_AddressType().setValue("W"); 1614 1615 XTN rol12 = theRol.insertRol12_Phone(0); 1616 rol12.getXtn1_TelephoneNumber().setValue("1(837)555-1978"); 1617 rol12.getXtn2_TelecommunicationUseCode().setValue("WPN"); 1618 rol12.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 1619 } 1620 1621 public void populateRolB(ROL rol2) throws HL7Exception { 1622 rol2.getRol3_RoleROL().getCe1_Identifier().setValue("ADM"); 1623 rol2.getRol3_RoleROL().getCe2_Text().setValue("admitter"); 1624 rol2.getRol3_RoleROL().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.PARTICIPANTTYPE_URI); 1625 rol2.getRol4_RolePerson(0).getXcn1_IDNumber().setValue("3622"); 1626 rol2.getRol4_RolePerson(0).getXcn2_FamilyName().getFn1_Surname().setValue("Hawkins"); 1627 rol2.getRol4_RolePerson(0).getXcn3_GivenName().setValue("Finnie"); 1628 rol2.getRol4_RolePerson(0) 1629 .getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof() 1630 .setValue("Winnie Pooh"); 1631 rol2.getRol4_RolePerson(0) 1632 .getXcn9_AssigningAuthority() 1633 .getHd1_NamespaceID() 1634 .setValue("http://acme.org/clinicians"); 1635 XAD rol11 = rol2.insertRol11_OfficeHomeAddressBirthplace(0); 1636 rol11.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("20 Canal St"); 1637 rol11.getXad3_City().setValue("Buffalo"); 1638 rol11.getXad4_StateOrProvince().setValue("NY"); 1639 rol11.getXad5_ZipOrPostalCode().setValue("98222"); 1640 rol11.getXad6_Country().setValue("USA"); 1641 rol11.getXad7_AddressType().setValue("W"); 1642 1643 XTN rol12 = rol2.insertRol12_Phone(0); 1644 rol12.getXtn1_TelephoneNumber().setValue("1(837)555-2133"); 1645 rol12.getXtn2_TelecommunicationUseCode().setValue("WPN"); 1646 rol12.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 1647 } 1648 1649 public void populateRolC(ROL rol3) throws HL7Exception { 1650 XAD rol11; 1651 XTN rol12; 1652 rol3.getRol3_RoleROL().getCe1_Identifier().setValue("ATND"); 1653 rol3.getRol3_RoleROL().getCe2_Text().setValue("attender"); 1654 rol3.getRol3_RoleROL().getCe3_NameOfCodingSystem().setValue(PublicApiConstants.PARTICIPANTTYPE_URI); 1655 rol3.getRol4_RolePerson(0).getXcn1_IDNumber().setValue("7452"); 1656 rol3.getRol4_RolePerson(0).getXcn2_FamilyName().getFn1_Surname().setValue("May"); 1657 rol3.getRol4_RolePerson(0).getXcn3_GivenName().setValue("Sadie"); 1658 rol3.getRol4_RolePerson(0) 1659 .getXcn9_AssigningAuthority() 1660 .getHd1_NamespaceID() 1661 .setValue("http://acme.org/clinicians"); 1662 1663 rol11 = rol3.insertRol11_OfficeHomeAddressBirthplace(0); 1664 rol11.getXad1_StreetAddress().getSad1_StreetOrMailingAddress().setValue("313 Fleet Street"); 1665 rol11.getXad3_City().setValue("Cheektowaga"); 1666 rol11.getXad4_StateOrProvince().setValue("NY"); 1667 rol11.getXad5_ZipOrPostalCode().setValue("28366"); 1668 rol11.getXad6_Country().setValue("USA"); 1669 rol11.getXad7_AddressType().setValue("W"); 1670 1671 rol12 = rol3.insertRol12_Phone(0); 1672 rol12.getXtn1_TelephoneNumber().setValue("1(837)555-6624"); 1673 rol12.getXtn2_TelecommunicationUseCode().setValue("WPN"); 1674 rol12.getXtn3_TelecommunicationEquipmentType().setValue("PH"); 1675 } 1676 1677 public void populateRxe(RXE theRxe) throws HL7Exception { 1678 theRxe.getRxe1_QuantityTiming().parse("^2 times daily&0900,1800^^20160205101500-0400^20160714165258-0400^R^^"); 1679 theRxe.getRxe2_GiveCode() 1680 .parse("02713^morphine injection 2 mg^http://acme.org/drugs^^^^^^Mighty Morphine Powder Dangers"); 1681 theRxe.getRxe3_GiveAmountMinimum().setValue("0.5"); 1682 theRxe.getRxe4_GiveAmountMaximum().setValue("2"); 1683 theRxe.getRxe5_GiveUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 1684 theRxe.getRxe7_ProviderSAdministrationInstructions(0).parse("^Take with Food"); 1685 theRxe.getRxe7_ProviderSAdministrationInstructions(1).parse("^Take at Night"); 1686 theRxe.getRxe10_DispenseAmount().setValue("1.2"); 1687 theRxe.getRxe11_DispenseUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 1688 theRxe.getRxe23_GiveRateAmount().setValue("1.0"); 1689 theRxe.getRxe24_GiveRateUnits().parse("mL/h^milliliter per hour^http://unitsofmeasure.org"); 1690 } 1691 1692 public void populateRxr(RXR theRxr) throws HL7Exception { 1693 theRxr.getRxr1_Route().parse("6064005^Topical^http://snomed.info/sct"); 1694 theRxr.getRxr2_AdministrationSite().parse("69536005^Head^http://snomed.info/sct"); 1695 } 1696 1697 public void populateSch(SCH theSch) throws HL7Exception { 1698 1699 theSch.getSch1_PlacerAppointmentID().getEi1_EntityIdentifier().parse("1234"); 1700 theSch.getSch1_PlacerAppointmentID().getEi2_NamespaceID().parse("http://acme.org/placer/321"); 1701 1702 theSch.getSch2_FillerAppointmentID().getEi1_EntityIdentifier().parse("1235"); 1703 theSch.getSch2_FillerAppointmentID().getEi2_NamespaceID().parse("http://acme.org/placer/322"); 1704 1705 theSch.getSch3_OccurrenceNumber().setValue("1"); 1706 1707 theSch.getSch6_EventReason().getCe1_Identifier().parse("22"); 1708 theSch.getSch6_EventReason().getCe2_Text().parse("Hypnotherapy"); // Maps to "Hypnotherapy" 1709 // ^ User-defined table in v2 but specific serviceType in FHIR 1710 1711 theSch.getSch7_AppointmentReason().getCe1_Identifier().parse("ROUTINE"); 1712 // ^ User-defined table in v2 but specific reasonCode in FHIR 1713 1714 theSch.getSch9_AppointmentDuration().setValue("30"); 1715 theSch.getSch10_AppointmentDurationUnits().getCe1_Identifier().setValue("minutes"); 1716 theSch.getSch11_AppointmentTimingQuantity(0) 1717 .getTq4_StartDateTime() 1718 .getTs1_Time() 1719 .setValue("202104141300-0500"); 1720 theSch.getSch11_AppointmentTimingQuantity(0) 1721 .getTq5_EndDateTime() 1722 .getTs1_Time() 1723 .setValue("202104141330-0500"); 1724 1725 // SCH-16 1726 theSch.getSch16_FillerContactPerson(0).getXcn1_IDNumber().setValue("2345"); 1727 theSch.getSch16_FillerContactPerson(0) 1728 .getXcn2_FamilyName() 1729 .getFn1_Surname() 1730 .setValue("Smith"); 1731 theSch.getSch16_FillerContactPerson(0).getXcn3_GivenName().setValue("Jane"); 1732 theSch.getSch16_FillerContactPerson(0) 1733 .getXcn9_AssigningAuthority() 1734 .getHd1_NamespaceID() 1735 .setValue("http://acme.org"); 1736 1737 theSch.getSch20_EnteredByPerson(0).getXcn1_IDNumber().setValue("3456"); 1738 theSch.getSch20_EnteredByPerson(0).getXcn2_FamilyName().getFn1_Surname().setValue("Coltrane"); 1739 theSch.getSch20_EnteredByPerson(0).getXcn3_GivenName().setValue("John"); 1740 theSch.getSch20_EnteredByPerson(0) 1741 .getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof() 1742 .setValue("William"); 1743 theSch.getSch20_EnteredByPerson(0) 1744 .getXcn9_AssigningAuthority() 1745 .getHd1_NamespaceID() 1746 .setValue("http://acme.org"); 1747 1748 theSch.getSch25_FillerStatusCode().getCe1_Identifier().setValue("Booked"); 1749 // ^ status (appointmentStatus) table in FHIR 1750 } 1751 1752 public void populateZxt(AbstractMessage theMsg) throws HL7Exception { 1753 /* 1754 * Extensions on Patient 1755 */ 1756 // Patient.active with boolean 1757 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))).parse("ZXT||ST|true|Patient.active"); 1758 // Patient.multipleBirthInteger with numeric 1759 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1760 .parse("ZXT||NM|3|Patient.multipleBirthInteger"); 1761 // Patient.extension with valueString 1762 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1763 .parse("ZXT||ST|Golly!|Patient.extension('http://acme.org/extension1').valueString"); 1764 // Patient.extension with nested extension with valueString 1765 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1766 .parse( 1767 "ZXT||ST|Gee!|Patient.extension('http://acme.org/extension2').extension('http://acme.org/nestedExtension1').valueString"); 1768 // Patient.extension with multiple nested extensions with valueString 1769 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1770 .parse( 1771 "ZXT||ST|Whiz!|Patient.extension('http://acme.org/extension3').extension('http://acme.org/nestedExtension2').extension('http://acme.org/nestedExtension3').valueString"); 1772 1773 /* 1774 * Extensions on Encounter 1775 */ 1776 // Encounter.extension with valueString 1777 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1778 .parse("ZXT||ST|Aces!|Encounter.extension('http://acme.org/extension4').valueString"); 1779 // Encounter.class.extension with valueString 1780 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1781 .parse( 1782 "ZXT||ST|Well, isn't that super?|Encounter.class.extension('http://acme.org/extension5').valueString"); 1783 // Encounter.extension with valueCoding 1784 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1785 .parse( 1786 "ZXT||CWE|CODE^This is a code.^http://acme.org/codes|Encounter.extension('http://acme.org/extension6').valueCoding"); 1787 // Encounter.extension with valueCodeableConcept, 1st code 1788 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1789 .parse( 1790 "ZXT||CWE|CODE1^This is a code1.^http://acme.org/codes|Encounter.extension('http://acme.org/extension7').valueCodeableConcept"); 1791 // Encounter.extension with valueCodeableConcept, 2nd code 1792 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1793 .parse( 1794 "ZXT||CWE|CODE2^This is a code2.^http://acme.org/codes|Encounter.extension('http://acme.org/extension7').valueCodeableConcept"); 1795 // Encounter.extension with valueInteger 1796 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1797 .parse("ZXT||NM|3|Encounter.extension('http://acme.org/extension8').valueInteger"); 1798 // Encounter.extension with valueDecimal 1799 ((AbstractSegment) theMsg.get(theMsg.addNonstandardSegment("ZXT"))) 1800 .parse("ZXT||NM|3.3|Encounter.extension('http://acme.org/extension9').valueDecimal"); 1801 } 1802 1803 public RAS_O17 createRasO17() throws HL7Exception { 1804 return createRasO17(false); 1805 } 1806 1807 public RAS_O17 createRasO17(boolean hasMultipleComponents) throws HL7Exception { 1808 return createRasO17(hasMultipleComponents, true, true, false); 1809 } 1810 1811 public RAS_O17 createRasO17(boolean hasMultipleComponents, boolean bothComponentsAreCoded) throws HL7Exception { 1812 return createRasO17(hasMultipleComponents, bothComponentsAreCoded, true, false); 1813 } 1814 1815 public RAS_O17 createRasO17( 1816 boolean hasMultipleComponents, 1817 boolean bothComponentsAreCoded, 1818 boolean thePopulateOrc2, 1819 boolean thePopulateOrc3) 1820 throws HL7Exception { 1821 RAS_O17 ras = new RAS_O17(); 1822 populateMsh(ras.getMSH(), "RAS^O17^RAS_O17"); 1823 populatePid(ras.getPATIENT().getPID(), true); 1824 populatePv1(ras.getPATIENT().getPATIENT_VISIT().getPV1()); 1825 1826 RAS_O17_ORDER order = ras.insertORDER(0); 1827 ORC orc = order.getORC(); 1828 populateOrcForMedication(orc, "NW", thePopulateOrc2, thePopulateOrc3); 1829 1830 populateRxe(ras.getORDER().getENCODING().getRXE()); 1831 populateRxr(ras.getORDER().getENCODING().getRXR()); 1832 1833 RXC rxc = ras.getORDER().getENCODING().insertRXC(0); 1834 rxc.getRxc1_RXComponentType().setValue("A"); 1835 rxc.getRxc2_ComponentCode().getCe1_Identifier().setValue("MEW"); 1836 rxc.getRxc2_ComponentCode().getCe2_Text().setValue("Kittens"); 1837 rxc.getRxc2_ComponentCode().getCe3_NameOfCodingSystem().setValue("http://acme.org/cats"); 1838 rxc.getRxc3_ComponentAmount().setValue("0.5"); 1839 rxc.getRxc4_ComponentUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 1840 1841 if (hasMultipleComponents) { 1842 if (bothComponentsAreCoded) { 1843 rxc = ras.getORDER().getENCODING().insertRXC(1); 1844 rxc.getRxc1_RXComponentType().setValue("B"); 1845 rxc.getRxc2_ComponentCode().getCe1_Identifier().setValue("WAF"); 1846 rxc.getRxc2_ComponentCode().getCe2_Text().setValue("Puppies"); 1847 rxc.getRxc2_ComponentCode().getCe3_NameOfCodingSystem().setValue("http://acme.org/dogs"); 1848 rxc.getRxc3_ComponentAmount().setValue("0.3"); 1849 rxc.getRxc4_ComponentUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 1850 } else { 1851 rxc = ras.getORDER().getENCODING().insertRXC(1); 1852 rxc.getRxc2_ComponentCode().getCe2_Text().setValue("Duckies"); 1853 rxc.getRxc3_ComponentAmount().setValue("0.2"); 1854 rxc.getRxc4_ComponentUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 1855 } 1856 } 1857 1858 RAS_O17_ADMINISTRATION admin = ras.getORDER().getADMINISTRATION(); 1859 1860 RXA rxa = admin.insertRXA(0); 1861 rxa.getRxa2_AdministrationSubIDCounter().setValue("1"); 1862 rxa.getRxa2_AdministrationSubIDCounter() 1863 .getExtraComponents() 1864 .getComponent(0) 1865 .getData() 1866 .parse("http://acme.org/medadmins"); 1867 rxa.getRxa3_DateTimeStartOfAdministration().getTs1_Time().setValue("20171209071055-0500"); 1868 rxa.getRxa4_DateTimeEndOfAdministration().getTs1_Time().setValue("20171209071100-0500"); 1869 rxa.getRxa5_AdministeredCode().getCe1_Identifier().setValue("0001"); 1870 rxa.getRxa5_AdministeredCode().getCe2_Text().setValue("Tylenol"); 1871 rxa.getRxa5_AdministeredCode().getCe3_NameOfCodingSystem().setValue("http://acme.org/meds"); 1872 rxa.getRxa6_AdministeredAmount().setValue("4"); 1873 rxa.getRxa7_AdministeredUnits().parse("mg^milligrams^http://unitsofmeasure.org"); 1874 rxa.getRxa9_AdministrationNotes(0).getCe2_Text().setValue("This is a note"); 1875 1876 rxa.getRxa10_AdministeringProvider(0).getXcn1_IDNumber().setValue("825"); 1877 rxa.getRxa10_AdministeringProvider(0) 1878 .getXcn2_FamilyName() 1879 .getFn1_Surname() 1880 .setValue("Bouvier"); 1881 rxa.getRxa10_AdministeringProvider(0).getXcn3_GivenName().setValue("Marge"); 1882 rxa.getRxa10_AdministeringProvider(0) 1883 .getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof() 1884 .setValue("Q"); 1885 rxa.getRxa10_AdministeringProvider(0) 1886 .getXcn9_AssigningAuthority() 1887 .getHd1_NamespaceID() 1888 .setValue("http://acme.org/clinicians"); 1889 1890 rxa.getRxa12_AdministeredPerTimeUnit().setValue("Day"); 1891 rxa.getRxa20_CompletionStatus().setValue("CP"); 1892 1893 populateRxr(admin.getRXR()); 1894 1895 ((AbstractSegment) admin.get(admin.addNonstandardSegment("ZXC"))) 1896 .parse("ZXC|A|MEW^Kittens^http://acme.org/cats|0.5|mg^milligrams^http://unitsofmeasure.org"); 1897 1898 if (hasMultipleComponents) { 1899 if (bothComponentsAreCoded) { 1900 ((AbstractSegment) admin.get(admin.addNonstandardSegment("ZXC"))) 1901 .parse("ZXC|B|WAF^Puppies^http://acme.org/dogs|0.3|mg^milligrams^http://unitsofmeasure.org"); 1902 } else { 1903 ((AbstractSegment) admin.get(admin.addNonstandardSegment("ZXC"))) 1904 .parse("ZXC||^Duckies|0.2|mg^milligrams^http://unitsofmeasure.org"); 1905 } 1906 } 1907 1908 return ras; 1909 } 1910 1911 public void populateXcn(XCN theXCN) throws DataTypeException { 1912 theXCN.getXcn1_IDNumber().setValue("777"); 1913 theXCN.getXcn2_FamilyName().getFn1_Surname().setValue("Jones"); 1914 theXCN.getXcn3_GivenName().setValue("Lisa"); 1915 theXCN.getXcn4_SecondAndFurtherGivenNamesOrInitialsThereof().setValue("Frances Little Piglet"); 1916 theXCN.getXcn5_SuffixEgJRorIII().setValue("Jr"); 1917 theXCN.getXcn6_PrefixEgDR().setValue("DR"); 1918 theXCN.getXcn7_DegreeEgMD().setValue("MD"); 1919 theXCN.getXcn9_AssigningAuthority().getHd1_NamespaceID().setValue("http://acme.org/clinicians"); 1920 } 1921}